SKE-42 change language in message after incorrect login

This commit is contained in:
Przemysław Stawujak 2018-12-01 23:30:47 +01:00
parent 23a46d9f28
commit 422fe1a99d
31 changed files with 372 additions and 2657 deletions

View File

@ -7,3 +7,4 @@ bin/
aspnet-core/src/SystemKonkursow.Web.Host/App_Data/Logs/
aspnet-core/src/SystemKonkursow.Web.Mvc/App_Data/Logs/
aspnet-core/src/SystemKonkursow.Migrator/Logs/Logs.txt
aspnet-core/src/SystemKonkursow.EntityFrameworkCore/Migrations/

View File

@ -3763,8 +3763,8 @@
"dev": true,
"optional": true,
"requires": {
"delegates": "^1.0.0",
"readable-stream": "^2.0.6"
"delegates": "1.0.0",
"readable-stream": "2.3.6"
}
},
"balanced-match": {
@ -3777,7 +3777,7 @@
"bundled": true,
"dev": true,
"requires": {
"balanced-match": "^1.0.0",
"balanced-match": "1.0.0",
"concat-map": "0.0.1"
}
},
@ -3841,7 +3841,7 @@
"dev": true,
"optional": true,
"requires": {
"minipass": "^2.2.1"
"minipass": "2.2.4"
}
},
"fs.realpath": {
@ -3856,14 +3856,14 @@
"dev": true,
"optional": true,
"requires": {
"aproba": "^1.0.3",
"console-control-strings": "^1.0.0",
"has-unicode": "^2.0.0",
"object-assign": "^4.1.0",
"signal-exit": "^3.0.0",
"string-width": "^1.0.1",
"strip-ansi": "^3.0.1",
"wide-align": "^1.1.0"
"aproba": "1.2.0",
"console-control-strings": "1.1.0",
"has-unicode": "2.0.1",
"object-assign": "4.1.1",
"signal-exit": "3.0.2",
"string-width": "1.0.2",
"strip-ansi": "3.0.1",
"wide-align": "1.1.2"
}
},
"glob": {
@ -3872,12 +3872,12 @@
"dev": true,
"optional": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
"fs.realpath": "1.0.0",
"inflight": "1.0.6",
"inherits": "2.0.3",
"minimatch": "3.0.4",
"once": "1.4.0",
"path-is-absolute": "1.0.1"
}
},
"has-unicode": {
@ -3892,7 +3892,7 @@
"dev": true,
"optional": true,
"requires": {
"safer-buffer": "^2.1.0"
"safer-buffer": "2.1.2"
}
},
"ignore-walk": {
@ -3901,7 +3901,7 @@
"dev": true,
"optional": true,
"requires": {
"minimatch": "^3.0.4"
"minimatch": "3.0.4"
}
},
"inflight": {
@ -3910,8 +3910,8 @@
"dev": true,
"optional": true,
"requires": {
"once": "^1.3.0",
"wrappy": "1"
"once": "1.4.0",
"wrappy": "1.0.2"
}
},
"inherits": {
@ -3930,7 +3930,7 @@
"bundled": true,
"dev": true,
"requires": {
"number-is-nan": "^1.0.0"
"number-is-nan": "1.0.1"
}
},
"isarray": {
@ -3944,7 +3944,7 @@
"bundled": true,
"dev": true,
"requires": {
"brace-expansion": "^1.1.7"
"brace-expansion": "1.1.11"
}
},
"minimist": {
@ -3957,8 +3957,8 @@
"bundled": true,
"dev": true,
"requires": {
"safe-buffer": "^5.1.1",
"yallist": "^3.0.0"
"safe-buffer": "5.1.1",
"yallist": "3.0.2"
}
},
"minizlib": {
@ -3967,7 +3967,7 @@
"dev": true,
"optional": true,
"requires": {
"minipass": "^2.2.1"
"minipass": "2.2.4"
}
},
"mkdirp": {
@ -3990,9 +3990,9 @@
"dev": true,
"optional": true,
"requires": {
"debug": "^2.1.2",
"iconv-lite": "^0.4.4",
"sax": "^1.2.4"
"debug": "2.6.9",
"iconv-lite": "0.4.21",
"sax": "1.2.4"
}
},
"node-pre-gyp": {
@ -4001,16 +4001,16 @@
"dev": true,
"optional": true,
"requires": {
"detect-libc": "^1.0.2",
"mkdirp": "^0.5.1",
"needle": "^2.2.0",
"nopt": "^4.0.1",
"npm-packlist": "^1.1.6",
"npmlog": "^4.0.2",
"rc": "^1.1.7",
"rimraf": "^2.6.1",
"semver": "^5.3.0",
"tar": "^4"
"detect-libc": "1.0.3",
"mkdirp": "0.5.1",
"needle": "2.2.0",
"nopt": "4.0.1",
"npm-packlist": "1.1.10",
"npmlog": "4.1.2",
"rc": "1.2.7",
"rimraf": "2.6.2",
"semver": "5.5.0",
"tar": "4.4.1"
}
},
"nopt": {
@ -4019,8 +4019,8 @@
"dev": true,
"optional": true,
"requires": {
"abbrev": "1",
"osenv": "^0.1.4"
"abbrev": "1.1.1",
"osenv": "0.1.5"
}
},
"npm-bundled": {
@ -4035,8 +4035,8 @@
"dev": true,
"optional": true,
"requires": {
"ignore-walk": "^3.0.1",
"npm-bundled": "^1.0.1"
"ignore-walk": "3.0.1",
"npm-bundled": "1.0.3"
}
},
"npmlog": {
@ -4045,10 +4045,10 @@
"dev": true,
"optional": true,
"requires": {
"are-we-there-yet": "~1.1.2",
"console-control-strings": "~1.1.0",
"gauge": "~2.7.3",
"set-blocking": "~2.0.0"
"are-we-there-yet": "1.1.4",
"console-control-strings": "1.1.0",
"gauge": "2.7.4",
"set-blocking": "2.0.0"
}
},
"number-is-nan": {
@ -4067,7 +4067,7 @@
"bundled": true,
"dev": true,
"requires": {
"wrappy": "1"
"wrappy": "1.0.2"
}
},
"os-homedir": {
@ -4088,8 +4088,8 @@
"dev": true,
"optional": true,
"requires": {
"os-homedir": "^1.0.0",
"os-tmpdir": "^1.0.0"
"os-homedir": "1.0.2",
"os-tmpdir": "1.0.2"
}
},
"path-is-absolute": {
@ -4110,10 +4110,10 @@
"dev": true,
"optional": true,
"requires": {
"deep-extend": "^0.5.1",
"ini": "~1.3.0",
"minimist": "^1.2.0",
"strip-json-comments": "~2.0.1"
"deep-extend": "0.5.1",
"ini": "1.3.5",
"minimist": "1.2.0",
"strip-json-comments": "2.0.1"
},
"dependencies": {
"minimist": {
@ -4130,13 +4130,13 @@
"dev": true,
"optional": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
"core-util-is": "1.0.2",
"inherits": "2.0.3",
"isarray": "1.0.0",
"process-nextick-args": "2.0.0",
"safe-buffer": "5.1.1",
"string_decoder": "1.1.1",
"util-deprecate": "1.0.2"
}
},
"rimraf": {
@ -4145,7 +4145,7 @@
"dev": true,
"optional": true,
"requires": {
"glob": "^7.0.5"
"glob": "7.1.2"
}
},
"safe-buffer": {
@ -4188,9 +4188,9 @@
"bundled": true,
"dev": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
"strip-ansi": "^3.0.0"
"code-point-at": "1.1.0",
"is-fullwidth-code-point": "1.0.0",
"strip-ansi": "3.0.1"
}
},
"string_decoder": {
@ -4199,7 +4199,7 @@
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "~5.1.0"
"safe-buffer": "5.1.1"
}
},
"strip-ansi": {
@ -4207,7 +4207,7 @@
"bundled": true,
"dev": true,
"requires": {
"ansi-regex": "^2.0.0"
"ansi-regex": "2.1.1"
}
},
"strip-json-comments": {
@ -4222,13 +4222,13 @@
"dev": true,
"optional": true,
"requires": {
"chownr": "^1.0.1",
"fs-minipass": "^1.2.5",
"minipass": "^2.2.4",
"minizlib": "^1.1.0",
"mkdirp": "^0.5.0",
"safe-buffer": "^5.1.1",
"yallist": "^3.0.2"
"chownr": "1.0.1",
"fs-minipass": "1.2.5",
"minipass": "2.2.4",
"minizlib": "1.1.0",
"mkdirp": "0.5.1",
"safe-buffer": "5.1.1",
"yallist": "3.0.2"
}
},
"util-deprecate": {
@ -4243,7 +4243,7 @@
"dev": true,
"optional": true,
"requires": {
"string-width": "^1.0.2"
"string-width": "1.0.2"
}
},
"wrappy": {
@ -9417,9 +9417,9 @@
}
},
"sweetalert": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/sweetalert/-/sweetalert-2.1.0.tgz",
"integrity": "sha512-9YKj0SvjKyBfRWco50UOsIbXVeifYbxzT9Qda7EsqC01eafHGCSG0IR7g942ufjzt7lnwO8ZZBwr6emXv2fQrg==",
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/sweetalert/-/sweetalert-2.1.2.tgz",
"integrity": "sha512-iWx7X4anRBNDa/a+AdTmvAzQtkN1+s4j/JJRWlHpYE8Qimkohs8/XnFcWeYHH2lMA8LRCa5tj2d244If3S/hzA==",
"requires": {
"es6-object-assign": "1.1.0",
"promise-polyfill": "6.1.0"

View File

@ -60,7 +60,7 @@
"rxjs": "^6.2.0",
"simple-line-icons": "^2.4.1",
"spin.js": "^2.3.2",
"sweetalert": "^2.0.8",
"sweetalert": "^2.1.2",
"toastr": "^2.1.2",
"ts-helpers": "^1.1.2",
"web-animations-js": "^2.3.1",

View File

@ -3,81 +3,27 @@
<div class="card">
<div class="header">
<h2>
About This Template
O projekcie
</h2>
</div>
<div class="body">
<p>
This is a simple startup template based on ASP.NET Boilerplate framework and Module Zero.
If you need an enterprise startup project, check <a href="http://aspnetzero.com?ref=abptmpl" target="_blank">ASP.NET ZERO</a>.
</p>
<h3>What is ASP.NET Boilerplate?</h3>
<p>
ASP.NET Boilerplate is an application framework built on latest <strong>ASP.NET Core</strong> framework.
It makes easy to use authorization, dependency injection, validation, exception handling, localization, logging, caching, background jobs and so on.
It's built on already familiar tools like Entity Framework, AutoMapper, Castle Windsor...
</p>
<p>
ASP.NET Boilerplate implements <strong>NLayer architecture</strong> (Domain, Application, Infrastructure and Presentation Layers)
and <strong>Domain Driven Design</strong> (Entities, Repositories, Domain/Application Services, DTO's...).
Also implements and provides a good infrastructure to implement common software development <strong>best practices</strong>.
</p>
<h3>What is Module Zero?</h3>
<p>
ASP.NET Boilerplate framework is designed to be independent of any database
schema and to be as generic as possible. Therefore, It leaves some concepts
<strong>abstract</strong> and <strong>optional</strong> (like audit logging, permission and setting stores)
which requires some <strong>data store</strong>.
</p>
<p>
<strong>Module Zero </strong>implements all fundamental concepts of ASP.NET
Boilerplate framework such as <a href="http://www.aspnetboilerplate.com/Pages/Documents/Zero/Tenant-Management">tenant management</a> (<strong>multi-tenancy</strong>),
<a href="http://www.aspnetboilerplate.com/Pages/Documents/Zero/Role-Management">
role management
</a>, <a href="http://www.aspnetboilerplate.com/Pages/Documents/Zero/User-Management">user management</a>,
<a href="http://www.aspnetboilerplate.com/Pages/Documents/Authorization">authorization</a> (<a href="http://www.aspnetboilerplate.com/Pages/Documents/Zero/Permission-Management">
permission management
</a>),
<a href="http://www.aspnetboilerplate.com/Pages/Documents/Setting-Management">setting management</a>, <a href="http://www.aspnetboilerplate.com/Pages/Documents/Zero/Language-Management">
language management
</a>, <a href="http://www.aspnetboilerplate.com/Pages/Documents/Audit-Logging">audit logging</a>
and so on.
</p>
<p>
Module-Zero defines entities and implements <strong>domain logic</strong>
(domain layer) and leaves application and presentation layers to you.
</p>
<h4>Based on Microsoft ASP.NET Core Identity</h4>
<p>
Module Zero is based on Microsoft's
<a href="https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity" target="_blank">ASP.NET Core Identity</a> library.
It extends user and role managers and implements user and role stores using generic repositories.
</p>
<h3>Documentation</h3>
<h3>NASZ ZESPÓŁ</h3>
<ul>
<li>
<a href="https://www.aspnetboilerplate.com/Pages/Documents/Zero/Startup-Template-Angular">Documentation for this template</a>
Izabela Kosmala
</li>
<li>
<a href="http://www.aspnetboilerplate.com/Pages/Documents">ASP.NET Boilerplate documentation</a>
Weronika Bola
</li>
<li>
Przemysław Stawujak
</li>
<li>
Marek Wendlandt
</li>
</ul>
<h3>Source code</h3>
<p>
This template is developed open source on Github. You can contribute to the template.
<a href="https://github.com/aspnetboilerplate/module-zero-core-template" target="_blank">https://github.com/aspnetboilerplate/module-zero-core-template</a>
</p>
</div>
</div>
</div>

View File

@ -1,7 +1,7 @@
<div [@routerTransition]>
<div class="block-header">
<h2>SAMPLE DASHBOARD</h2>
<h2>KALENDARZ</h2>
</div>
<!-- Widgets -->

View File

@ -1,7 +1,7 @@
<aside id="rightsidebar" class="right-sidebar">
<ul class="nav nav-tabs tab-nav-right" role="tablist">
<li role="presentation" class="active"><a href="#skins" data-toggle="tab">SKINS</a></li>
<li role="presentation"><a href="#settings" data-toggle="tab">SETTINGS</a></li>
<li role="presentation" class="active"><a href="#skins" data-toggle="tab">KOLOR</a></li>
<!-- <li role="presentation"><a href="#settings" data-toggle="tab">SETTINGS</a></li> -->
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade in active in active" id="skins">
@ -12,7 +12,7 @@
</li>
</ul>
</div>
<div role="tabpanel" class="tab-pane fade" id="settings">
<!-- <div role="tabpanel" class="tab-pane fade" id="settings">
<div class="demo-settings">
<p>GENERAL SETTINGS</p>
<ul class="setting-list">
@ -60,6 +60,6 @@
</li>
</ul>
</div>
</div>
</div> -->
</div>
</aside>

View File

@ -10,29 +10,29 @@ import { ConfigurationServiceProxy, ChangeUiThemeInput } from '@shared/service-p
export class RightSideBarComponent extends AppComponentBase implements OnInit {
themes: UiThemeInfo[] = [
new UiThemeInfo("Red", "red"),
new UiThemeInfo("Pink", "pink"),
new UiThemeInfo("Purple", "purple"),
new UiThemeInfo("Deep Purple", "deep-purple"),
new UiThemeInfo("Indigo", "indigo"),
new UiThemeInfo("Blue", "blue"),
new UiThemeInfo("Light Blue", "light-blue"),
new UiThemeInfo("Cyan", "cyan"),
new UiThemeInfo("Teal", "teal"),
new UiThemeInfo("Green", "green"),
new UiThemeInfo("Light Green", "light-green"),
new UiThemeInfo("Lime", "lime"),
new UiThemeInfo("Yellow", "yellow"),
new UiThemeInfo("Amber", "amber"),
new UiThemeInfo("Orange", "orange"),
new UiThemeInfo("Deep Orange", "deep-orange"),
new UiThemeInfo("Brown", "brown"),
new UiThemeInfo("Grey", "grey"),
new UiThemeInfo("Blue Grey", "blue-grey"),
new UiThemeInfo("Black", "black")
new UiThemeInfo("Czerwony", "red"),
new UiThemeInfo("Różowy", "pink"),
new UiThemeInfo("Fioletowy", "purple"),
new UiThemeInfo("Ciemnofioletowy", "deep-purple"),
new UiThemeInfo("Indygo", "indigo"),
new UiThemeInfo("Niebieski", "blue"),
new UiThemeInfo("Jasnoniebieski", "light-blue"),
new UiThemeInfo("Cyjan", "cyan"),
new UiThemeInfo("Turkusowy", "teal"),
new UiThemeInfo("Zielony", "green"),
new UiThemeInfo("Jasnozielony", "light-green"),
new UiThemeInfo("Limonkowy", "lime"),
new UiThemeInfo("Żółty", "yellow"),
new UiThemeInfo("Bursztynowy", "amber"),
new UiThemeInfo("Pomarańczowy", "orange"),
new UiThemeInfo("Ciemnopomarańczowy", "deep-orange"),
new UiThemeInfo("Brązowy", "brown"),
new UiThemeInfo("Szary", "grey"),
new UiThemeInfo("Ciemnoszary", "blue-grey"),
new UiThemeInfo("Czarny", "black")
];
selectedThemeCssClass: string = "red";
selectedThemeCssClass: string = "blue";
constructor(
injector: Injector,

View File

@ -3,6 +3,6 @@
&copy; {{currentYear}} <a href="javascript:void(0);">SystemKonkursow</a>.
</div>
<div class="version">
<b>Version </b> {{versionText}}
<b>Wersja </b> {{versionText}}
</div>
</div>

View File

@ -10,29 +10,29 @@ import { MenuItem } from '@shared/layout/menu-item';
export class SideBarNavComponent extends AppComponentBase {
menuItems: MenuItem[] = [
new MenuItem(this.l("HomePage"), "", "home", "/app/home"),
new MenuItem(this.l("Strona domowa"), "", "home", "/app/home"),
new MenuItem(this.l("Tenants"), "Pages.Tenants", "business", "/app/tenants"),
new MenuItem(this.l("Users"), "Pages.Users", "people", "/app/users"),
new MenuItem(this.l("Roles"), "Pages.Roles", "local_offer", "/app/roles"),
new MenuItem(this.l("About"), "", "info", "/app/about"),
new MenuItem(this.l("Użytkownicy"), "Pages.Users", "people", "/app/users"),
new MenuItem(this.l("Role"), "Pages.Roles", "local_offer", "/app/roles"),
new MenuItem(this.l("O projekcie"), "", "info", "/app/about"),
new MenuItem(this.l("MultiLevelMenu"), "", "menu", "", [
new MenuItem("ASP.NET Boilerplate", "", "", "", [
new MenuItem("Home", "", "", "https://aspnetboilerplate.com/?ref=abptmpl"),
new MenuItem("Templates", "", "", "https://aspnetboilerplate.com/Templates?ref=abptmpl"),
new MenuItem("Samples", "", "", "https://aspnetboilerplate.com/Samples?ref=abptmpl"),
new MenuItem("Documents", "", "", "https://aspnetboilerplate.com/Pages/Documents?ref=abptmpl")
]),
new MenuItem("ASP.NET Zero", "", "", "", [
new MenuItem("Home", "", "", "https://aspnetzero.com?ref=abptmpl"),
new MenuItem("Description", "", "", "https://aspnetzero.com/?ref=abptmpl#description"),
new MenuItem("Features", "", "", "https://aspnetzero.com/?ref=abptmpl#features"),
new MenuItem("Pricing", "", "", "https://aspnetzero.com/?ref=abptmpl#pricing"),
new MenuItem("Faq", "", "", "https://aspnetzero.com/Faq?ref=abptmpl"),
new MenuItem("Documents", "", "", "https://aspnetzero.com/Documents?ref=abptmpl")
])
])
// new MenuItem(this.l("MultiLevelMenu"), "", "menu", "", [
// new MenuItem("ASP.NET Boilerplate", "", "", "", [
// new MenuItem("Home", "", "", "https://aspnetboilerplate.com/?ref=abptmpl"),
// new MenuItem("Templates", "", "", "https://aspnetboilerplate.com/Templates?ref=abptmpl"),
// new MenuItem("Samples", "", "", "https://aspnetboilerplate.com/Samples?ref=abptmpl"),
// new MenuItem("Documents", "", "", "https://aspnetboilerplate.com/Pages/Documents?ref=abptmpl")
// ]),
// new MenuItem("ASP.NET Zero", "", "", "", [
// new MenuItem("Home", "", "", "https://aspnetzero.com?ref=abptmpl"),
// new MenuItem("Description", "", "", "https://aspnetzero.com/?ref=abptmpl#description"),
// new MenuItem("Features", "", "", "https://aspnetzero.com/?ref=abptmpl#features"),
// new MenuItem("Pricing", "", "", "https://aspnetzero.com/?ref=abptmpl#pricing"),
// new MenuItem("Faq", "", "", "https://aspnetzero.com/Faq?ref=abptmpl"),
// new MenuItem("Documents", "", "", "https://aspnetzero.com/Documents?ref=abptmpl")
// ])
// ])
];
constructor(

View File

@ -3,7 +3,7 @@
<div class="search-icon">
<i class="material-icons">search</i>
</div>
<input materialInput type="text" placeholder="START TYPING...">
<input materialInput type="text" placeholder="ZACZNIJ PISAĆ...">
<div class="close-search">
<i class="material-icons">close</i>
</div>

View File

@ -10,7 +10,7 @@
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">
<span>{{l("CreateNewRole")}}</span>
<span>{{l("Tworzenie roli")}}</span>
</h4>
</div>
<div class="modal-body">
@ -19,7 +19,7 @@
<div class="form-group form-float">
<div class="form-line">
<input id="rolename" type="text" name="RoleName" [(ngModel)]="role.name" required maxlength="32" minlength="2" class="validate form-control">
<label for="rolename" class="form-label">{{l("RoleName")}}</label>
<label for="rolename" class="form-label">{{l("Nazwa roli")}}</label>
</div>
</div>
</div>
@ -30,7 +30,7 @@
<div class="form-group form-float">
<div class="form-line">
<input id="displayname" type="text" name="DisplayName" [(ngModel)]="role.displayName" required maxlength="32" minlength="2" class="validate form-control">
<label for="displayname" class="form-label">{{l("DisplayName")}}</label>
<label for="displayname" class="form-label">{{l("Wyświetlana nazwa roli")}}</label>
</div>
</div>
</div>
@ -41,7 +41,7 @@
<div class="form-group form-float">
<div class="form-line">
<textarea id="role-description" name="Description" [(ngModel)]="role.description" class="validate form-control"></textarea>
<label for="role-description" class="form-label">Role Description</label>
<label for="role-description" class="form-label">Opis roli</label>
</div>
</div>
</div>
@ -49,7 +49,7 @@
<div class="row clearfix">
<div class="col-sm-12">
<h4>Permissions</h4>
<h4>Uprawnienia</h4>
<ng-template ngFor let-permission [ngForOf]="permissions.items" let-permissionIndex="index">
<div class="col-sm-6">
<input type="checkbox" name="permission" value="{{permission.name}}" class="filled-in" id="permission-{{permissionIndex}}" checked="checked" />
@ -62,10 +62,10 @@
<div class="modal-footer">
<button [disabled]="saving" type="button" class="btn btn-default waves-effect" (click)="close()">
{{l("Cancel")}}
{{l("Anuluj")}}
</button>
<button [disabled]="!createRoleForm.form.valid || saving" type="submit" class="btn btn-primary waves-effect">
{{l("Save")}}
{{l("Zapisz")}}
</button>
</div>

View File

@ -61,7 +61,7 @@ export class CreateRoleComponent extends AppComponentBase implements OnInit {
this._roleService.create(this.role)
.pipe(finalize(() => { this.saving = false; }))
.subscribe(() => {
this.notify.info(this.l('SavedSuccessfully'));
this.notify.info(this.l('Zapisano pomyślnie'));
this.close();
this.modalSave.emit(null);
});

View File

@ -10,7 +10,7 @@
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">
<span>{{l("EditRole")}} <span *ngIf="model.role.isStatic"> (<span style="color:red">static</span>)</span></span>
<span>{{l("Edycja roli")}} <span *ngIf="model.role.isStatic"> (<span style="color:red">static</span>)</span></span>
</h4>
</div>
<div class="modal-body">
@ -20,7 +20,7 @@
<div class="form-group form-float">
<div class="form-line">
<input id="rolename" [disabled]="model.role.isStatic" type="text" name="RoleName" [(ngModel)]="model.role.name" required maxlength="32" minlength="2" class="validate form-control">
<label for="rolename" class="form-label">{{l("RoleName")}}</label>
<label for="rolename" class="form-label">{{l("Nazwa roli")}}</label>
</div>
</div>
</div>
@ -31,7 +31,7 @@
<div class="form-group form-float">
<div class="form-line">
<input id="displayname" type="text" name="DisplayName" [(ngModel)]="model.role.displayName" required maxlength="32" minlength="2" class="validate form-control">
<label for="displayname" class="form-label">{{l("DisplayName")}}</label>
<label for="displayname" class="form-label">{{l("Wyświetlana nazwa roli")}}</label>
</div>
</div>
</div>
@ -42,7 +42,7 @@
<div class="form-group form-float">
<div class="form-line">
<textarea id="role-description" name="Description" [(ngModel)]="model.role.description" class="validate form-control"></textarea>
<label for="role-description" class="form-label">Role Description</label>
<label for="role-description" class="form-label">Opis roli</label>
</div>
</div>
</div>
@ -50,7 +50,7 @@
<div class="row clearfix">
<div class="col-sm-12">
<h4>Permissions</h4>
<h4>Uprawnienia</h4>
<ng-template ngFor let-permission [ngForOf]="model.permissions" let-permissionIndex="index">
<div class="col-sm-6">
@ -64,10 +64,10 @@
</div>
<div class="modal-footer">
<button [disabled]="saving" type="button" class="btn btn-default waves-effect" (click)="close()">
{{l("Cancel")}}
{{l("Anuluj")}}
</button>
<button [disabled]="!editRoleForm.form.valid || saving" type="submit" class="btn btn-primary waves-effect">
{{l("Save")}}
{{l("Zapisz")}}
</button>
</div>

View File

@ -75,7 +75,7 @@ export class EditRoleComponent extends AppComponentBase {
this._roleService.update(input)
.pipe(finalize(() => { this.saving = false; }))
.subscribe(() => {
this.notify.info(this.l('SavedSuccessfully'));
this.notify.info(this.l('Zapisano pomyślnie'));
this.close();
this.modalSave.emit(null);
});

View File

@ -3,7 +3,7 @@
<div class="card main-content">
<div class="header">
<h2>
{{l('Roles')}}
{{l('Role')}}
</h2>
<ul class="header-dropdown m-r--5">
<i class="fa fa-spin fa-spinner" *ngIf="isTableLoading"></i>
@ -12,7 +12,7 @@
<i class="material-icons">more_vert</i>
</a>
<ul class="dropdown-menu pull-right">
<li><a href="javascript:void(0);" class=" waves-effect <waves-block></waves-block>" (click)="refresh();"><i class="material-icons">refresh</i> Refresh</a></li>
<li><a href="javascript:void(0);" class=" waves-effect <waves-block></waves-block>" (click)="refresh();"><i class="material-icons">refresh</i>Odśwież</a></li>
</ul>
</li>
</ul>
@ -22,9 +22,9 @@
<table class="table table-hover table-striped">
<thead>
<tr>
<th>{{l('RoleName')}}</th>
<th>{{l('DisplayName')}}</th>
<th>{{l('Actions')}}</th>
<th>{{l('Nazwa roli')}}</th>
<th>{{l('Wyświetlana nazwa roli')}}</th>
<th>{{l('Akcje')}}</th>
</tr>
</thead>
<tbody>
@ -36,8 +36,8 @@
<i class="material-icons">menu</i>
</a>
<ul class="dropdown-menu pull-right">
<li><a href="javascript:void(0);" class="waves-effect waves-block" (click)="editRole(role)"><i class="material-icons">create</i>Edit</a></li>
<li><a href="javascript:void(0);" class="waves-effect waves-block" (click)="delete(role)"><i class="material-icons">delete_sweep</i>Delete</a></li>
<li><a href="javascript:void(0);" class="waves-effect waves-block" (click)="editRole(role)"><i class="material-icons">create</i>Edytuj</a></li>
<li><a href="javascript:void(0);" class="waves-effect waves-block" (click)="delete(role)"><i class="material-icons">delete_sweep</i>Usuń</a></li>
</ul>
</td>
</tr>

View File

@ -5,6 +5,7 @@ import { appModuleAnimation } from '@shared/animations/routerTransition';
import { CreateRoleComponent } from 'app/roles/create-role/create-role.component';
import { EditRoleComponent } from 'app/roles/edit-role/edit-role.component';
import { finalize } from 'rxjs/operators';
import swal from 'sweetalert';
@Component({
templateUrl: './roles.component.html',
@ -34,21 +35,22 @@ export class RolesComponent extends PagedListingComponentBase<RoleDto> {
}
delete(role: RoleDto): void {
abp.message.confirm(
"Remove Users from Role and delete Role '"+ role.displayName +"'?",
"Permanently delete this Role",
(result:boolean) =>{
if(result)
{
this.rolesService.delete(role.id)
.pipe(finalize(() => {
abp.notify.info("Deleted Role: " + role.displayName);
this.refresh();
}))
.subscribe(() => { });
}
}
);
swal({
title: "Usuwanie roli",
text: "Czy usunąć role '"+ role.displayName +"'?",
icon: "warning",
buttons: ['Anuluj', 'Tak']
}).then(result => {
if (result) {
this.rolesService.delete(role.id)
.subscribe(() => {
this.refresh();
swal("Usunięto role: " + role.displayName, {
icon: "success",
});
});
}
});
}
// Show Modals

View File

@ -9,14 +9,14 @@
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">
<span>{{l("CreateNewUser")}}</span>
<span>{{l("Tworzenie użytkownika")}}</span>
</h4>
</div>
<div class="modal-body">
<ul class="nav nav-tabs tab-nav-right" role="tablist">
<li role="presentation" class="active"><a href="#user-details" data-toggle="tab">User Details</a></li>
<li role="presentation"><a href="#user-roles" data-toggle="tab">User Roles</a></li>
<li role="presentation" class="active"><a href="#user-details" data-toggle="tab">Dane użytkownika</a></li>
<li role="presentation"><a href="#user-roles" data-toggle="tab">Role użytkownika</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane animated fadeIn active" id="user-details">
@ -26,7 +26,7 @@
<div class="form-group form-float">
<div class="form-line">
<input id="username" type="text" name="UserName" [(ngModel)]="user.userName" required maxlength="32" minlength="2" class="validate form-control">
<label for="username" class="form-label">{{l("UserName")}}</label>
<label for="username" class="form-label">{{l("Nazwa użytkownika")}}</label>
</div>
</div>
</div>
@ -37,7 +37,7 @@
<div class="form-group form-float">
<div class="form-line">
<input id="name" type="text" name="Name" [(ngModel)]="user.name" required maxlength="32" class="validate form-control">
<label for="name" class="form-label">{{l("Name")}}</label>
<label for="name" class="form-label">{{l("Imię")}}</label>
</div>
</div>
</div>
@ -45,7 +45,7 @@
<div class="form-group form-float">
<div class="form-line">
<input id="surname" type="text" name="Surname" [(ngModel)]="user.surname" required maxlength="32" class="validate form-control">
<label for="surname" class="form-label">{{l("Surname")}}</label>
<label for="surname" class="form-label">{{l("Nazwisko")}}</label>
</div>
</div>
</div>
@ -56,7 +56,7 @@
<div class="form-group form-float">
<div class="form-line">
<input id="email" type="email" name="EmailAddress" [(ngModel)]="user.emailAddress" maxlength="256" pattern="^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$" class="validate form-control">
<label for="email" class="form-label">{{l("EmailAddress")}}</label>
<label for="email" class="form-label">{{l("Adres e-mail")}}</label>
</div>
</div>
</div>
@ -67,7 +67,7 @@
<div class="form-group form-float">
<div class="form-line">
<input id="password" type="password" name="Password" [(ngModel)]="user.password" required maxlength="32" class="validate form-control">
<label for="password" class="form-label">{{l("Password")}}</label>
<label for="password" class="form-label">{{l("Hasło")}}</label>
</div>
</div>
</div>
@ -77,8 +77,8 @@
<div class="col-sm-12">
<div class="form-group form-float">
<div class="form-line">
<input id="confirmpassword" type="password" name="ConfirmPassword" class="validate form-control" [(ngModel)]="user.confirmPassword" equalTo="#password" data-msg-equalto="Please enter the same password again." required maxlength="32">
<label for="confirmpassword" class="form-label">{{l("ConfirmPassword")}}</label>
<input id="confirmpassword" type="password" name="ConfirmPassword" class="validate form-control" [(ngModel)]="confirmationPassword" required maxlength="32">
<label for="confirmpassword" class="form-label">{{l("Potwierdzenie hasła")}}</label>
</div>
</div>
</div>
@ -89,7 +89,7 @@
<div class="form-group form-float">
<div class="">
<input id="isactive" type="checkbox" name="IsActive" [(ngModel)]="user.isActive" checked class="form-control" />
<label for="isactive" class="form-label">{{l("IsActive")}}</label>
<label for="isactive" class="form-label">{{l("Aktywny")}}</label>
</div>
</div>
</div>
@ -113,10 +113,10 @@
</div>
<div class="modal-footer">
<button [disabled]="saving" type="button" class="btn btn-default waves-effect" (click)="close()">
{{l("Cancel")}}
{{l("Anuluj")}}
</button>
<button [disabled]="!createUserForm.form.valid || saving" type="submit" class="btn btn-primary waves-effect">
{{l("Save")}}
{{l("Zapisz")}}
</button>
</div>

View File

@ -3,6 +3,7 @@ import { ModalDirective } from 'ngx-bootstrap';
import { UserServiceProxy, CreateUserDto, RoleDto } from '@shared/service-proxies/service-proxies';
import { AppComponentBase } from '@shared/app-component-base';
import { finalize } from 'rxjs/operators';
import swal from 'sweetalert';
@Component({
selector: 'create-user-modal',
@ -19,6 +20,7 @@ export class CreateUserComponent extends AppComponentBase implements OnInit {
saving: boolean = false;
user: CreateUserDto = null;
roles: RoleDto[] = null;
confirmationPassword: string = '';
constructor(
injector: Injector,
@ -47,22 +49,31 @@ export class CreateUserComponent extends AppComponentBase implements OnInit {
save(): void {
//TODO: Refactor this, don't use jQuery style code
var roles = [];
$(this.modalContent.nativeElement).find("[name=role]").each((ind:number, elem:Element) => {
if($(elem).is(":checked") == true){
roles.push(elem.getAttribute("value").valueOf());
}
});
this.user.roleNames = roles;
this.saving = true;
this._userService.create(this.user)
.pipe(finalize(() => { this.saving = false; }))
.subscribe(() => {
this.notify.info(this.l('SavedSuccessfully'));
this.close();
this.modalSave.emit(null);
if (this.user.password === this.confirmationPassword) {
var roles = [];
$(this.modalContent.nativeElement).find("[name=role]").each((ind:number, elem:Element) => {
if($(elem).is(":checked") == true){
roles.push(elem.getAttribute("value").valueOf());
}
});
this.user.roleNames = roles;
this.saving = true;
this._userService.create(this.user)
.pipe(finalize(() => { this.saving = false; }))
.subscribe(() => {
this.notify.info(this.l('Zapisano pomyślnie'));
this.close();
this.modalSave.emit(null);
});
} else {
swal({
title: "Błąd - Hasło!",
text: "Proszę podaj takie same hasła",
icon: "error"
})
}
}
close(): void {

View File

@ -8,13 +8,13 @@
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">
<span>{{l("EditUser")}}</span>
<span>{{l("Edycja użytkownika")}}</span>
</h4>
</div>
<div class="modal-body">
<ul class="nav nav-tabs tab-nav-right" role="tablist">
<li role="presentation" class="active"><a href="#edit-user-details" data-toggle="tab">User Details</a></li>
<li role="presentation"><a href="#edit-user-roles" data-toggle="tab">User Roles</a></li>
<li role="presentation" class="active"><a href="#edit-user-details" data-toggle="tab">Dane użytkownika</a></li>
<li role="presentation"><a href="#edit-user-roles" data-toggle="tab">Role użytkownika</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane animated fadeIn active" id="edit-user-details">
@ -24,7 +24,7 @@
<div class="form-group form-float">
<div class="form-line">
<input id="username" type="text" name="UserName" [(ngModel)]="user.userName" required maxlength="32" minlength="2" class="validate form-control">
<label for="username" class="form-label">{{l("UserName")}}</label>
<label for="username" class="form-label">{{l("Nazwa użytkownika")}}</label>
</div>
</div>
</div>
@ -35,7 +35,7 @@
<div class="form-group form-float">
<div class="form-line">
<input id="name" type="text" name="Name" [(ngModel)]="user.name" required maxlength="32" class="validate form-control">
<label for="name" class="form-label">{{l("Name")}}</label>
<label for="name" class="form-label">{{l("Imię")}}</label>
</div>
</div>
</div>
@ -43,7 +43,7 @@
<div class="form-group form-float">
<div class="form-line">
<input id="surname" type="text" name="Surname" [(ngModel)]="user.surname" required maxlength="32" class="validate form-control">
<label for="surname" class="form-label">{{l("Surname")}}</label>
<label for="surname" class="form-label">{{l("Nazwisko")}}</label>
</div>
</div>
</div>
@ -54,7 +54,7 @@
<div class="form-group form-float">
<div class="form-line">
<input id="email" type="email" name="EmailAddress" [(ngModel)]="user.emailAddress" maxlength="256" pattern="^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$" class="validate form-control">
<label for="email" class="form-label">{{l("EmailAddress")}}</label>
<label for="email" class="form-label">{{l("Adres e-mail")}}</label>
</div>
</div>
</div>
@ -65,7 +65,7 @@
<div class="form-group form-float">
<div class="">
<input id="isactive" type="checkbox" name="IsActive" [(ngModel)]="user.isActive" checked class="form-control" />
<label for="isactive" class="form-label">{{l("IsActive")}}</label>
<label for="isactive" class="form-label">{{l("Aktywny")}}</label>
</div>
</div>
</div>
@ -89,10 +89,10 @@
</div>
<div class="modal-footer">
<button [disabled]="saving" type="button" class="btn btn-default waves-effect" (click)="close()">
{{l("Cancel")}}
{{l("Anuluj")}}
</button>
<button [disabled]="!editUserForm.form.valid" type="submit" class="btn btn-primary waves-effect">
{{l("Save")}}
{{l("Zapisz")}}
</button>
</div>

View File

@ -71,7 +71,7 @@ export class EditUserComponent extends AppComponentBase {
this._userService.update(this.user)
.pipe(finalize(() => { this.saving = false; }))
.subscribe(() => {
this.notify.info(this.l('SavedSuccessfully'));
this.notify.info(this.l('Zapisano pomyślnie'));
this.close();
this.modalSave.emit(null);
});

View File

@ -3,7 +3,7 @@
<div class="card main-content">
<div class="header">
<h2>
{{l('Users')}}
{{l('Użytkownicy')}}
</h2>
<ul class="header-dropdown m-r--5">
<i class="fa fa-spin fa-spinner" *ngIf="isTableLoading"></i>
@ -12,7 +12,7 @@
<i class="material-icons">more_vert</i>
</a>
<ul class="dropdown-menu pull-right">
<li><a href="javascript:void(0);" class=" waves-effect waves-block()" (click)="refresh();"><i class="material-icons">refresh</i> {{l('Refresh')}}</a></li>
<li><a href="javascript:void(0);" class=" waves-effect waves-block()" (click)="refresh();"><i class="material-icons">refresh</i> {{l('Odśwież')}}</a></li>
</ul>
</li>
</ul>
@ -23,13 +23,13 @@
<table class="table table-hover table-striped">
<thead>
<tr>
<th>{{l('UserName')}}</th>
<th>{{l('FullName')}}</th>
<th>{{l('EmailAddress')}}</th>
<th>{{l('Nazwa użytkownika')}}</th>
<th>{{l('Imię i nazwisko')}}</th>
<th>{{l('Adres e-mail')}}</th>
<th>
<div style="text-align:center">{{l('IsActive')}}</div>
<div style="text-align:center">{{l('Aktywny')}}</div>
</th>
<th>{{l('Actions')}}</th>
<th>{{l('Akcje')}}</th>
</tr>
</thead>
<tbody>
@ -46,8 +46,8 @@
<i class="material-icons">menu</i>
</a>
<ul class="dropdown-menu pull-right">
<li><a href="javascript:void(0);" class="waves-effect waves-block" (click)="editUser(user)"><i class="material-icons">create</i>{{l('Edit')}}</a></li>
<li><a href="javascript:void(0);" class="waves-effect waves-block" (click)="delete(user)"><i class="material-icons">delete_sweep</i>{{l('Delete')}}</a></li>
<li><a href="javascript:void(0);" class="waves-effect waves-block" (click)="editUser(user)"><i class="material-icons">create</i>{{l('Edytuj')}}</a></li>
<li><a href="javascript:void(0);" class="waves-effect waves-block" (click)="delete(user)"><i class="material-icons">delete_sweep</i>{{l('Usuń')}}</a></li>
</ul>
</td>
</tr>

View File

@ -5,6 +5,7 @@ import { PagedListingComponentBase, PagedRequestDto } from 'shared/paged-listing
import { CreateUserComponent } from 'app/users/create-user/create-user.component';
import { EditUserComponent } from 'app/users/edit-user/edit-user.component';
import { finalize } from 'rxjs/operators';
import swal from 'sweetalert';
@Component({
templateUrl: './users.component.html',
@ -37,18 +38,22 @@ export class UsersComponent extends PagedListingComponentBase<UserDto> {
}
protected delete(user: UserDto): void {
abp.message.confirm(
"Delete user '" + user.fullName + "'?",
(result: boolean) => {
if (result) {
this._userService.delete(user.id)
.subscribe(() => {
abp.notify.info("Deleted User: " + user.fullName);
this.refresh();
swal({
title: "Usuwanie użytkownika",
text: "Czy usunąć użytkownika '" + user.fullName + "'?",
icon: "warning",
buttons: ['Anuluj', 'Tak']
}).then(result => {
if (result) {
this._userService.delete(user.id)
.subscribe(() => {
this.refresh();
swal("Usunięto użytkownika: " + user.fullName, {
icon: "success",
});
}
});
}
);
});
}
// Show Modals

View File

@ -7,5 +7,9 @@
public const string Pages_Users = "Pages.Users";
public const string Pages_Roles = "Pages.Roles";
public const string Pages_Create_Competition = "Pages.Create.Competition";
public const string Pages_Solve_Competition = "Pages.Solve.Competition";
}
}

View File

@ -5,6 +5,8 @@ namespace SystemKonkursow.Authorization.Roles
public static class Host
{
public const string Admin = "Admin";
public const string Organizer = "Organizator";
public const string Participant = "Uczestnik";
}
public static class Tenants

View File

@ -10,6 +10,8 @@ namespace SystemKonkursow.Authorization
{
context.CreatePermission(PermissionNames.Pages_Users, L("Users"));
context.CreatePermission(PermissionNames.Pages_Roles, L("Roles"));
context.CreatePermission(PermissionNames.Pages_Create_Competition, L("CreateCompetition"));
context.CreatePermission(PermissionNames.Pages_Solve_Competition, L("SolveCompetition"));
context.CreatePermission(PermissionNames.Pages_Tenants, L("Tenants"), multiTenancySides: MultiTenancySides.Host);
}

View File

@ -9,7 +9,7 @@ namespace SystemKonkursow.Configuration
{
return new[]
{
new SettingDefinition(AppSettingNames.UiTheme, "red", scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true)
new SettingDefinition(AppSettingNames.UiTheme, "blue", scopes: SettingScopes.Application | SettingScopes.Tenant | SettingScopes.User, isVisibleToClients: true)
};
}
}

View File

@ -6,19 +6,19 @@
<text name="WellcomeMessage" value="Welcome to SystemKonkursow!" />
<text name="FormIsNotValidMessage" value="Form is not valid. Please check and fix errors." />
<text name="TenantNameCanNotBeEmpty" value="Tenant name can not be empty" />
<text name="InvalidUserNameOrPassword" value="Invalid user name or password" />
<text name="InvalidUserNameOrPassword" value="Niepoprawna nazwa użytkownika lub hasło" />
<text name="ThereIsNoTenantDefinedWithName{0}" value="There is no tenant defined with name {0}" />
<text name="TenantIsNotActive" value="Tenant {0} is not active." />
<text name="UserIsNotActiveAndCanNotLogin" value="User {0} is not active and can not log in." />
<text name="UserEmailIsNotConfirmedAndCanNotLogin">Your email address is not confirmed. You can not login.</text>
<text name="UserLockedOutMessage">The user account has been locked out. Please try again later.</text>
<text name="UserIsNotActiveAndCanNotLogin" value="Użytkownik {0} jest nieaktywny." />
<text name="UserEmailIsNotConfirmedAndCanNotLogin">Twój adres e-mail jest niepotwierdzony. Nie możesz się zalogować.</text>
<text name="UserLockedOutMessage">To konto jest zablokowane. Spróbuj później.</text>
<text name="PleaseEnterLoginInformation" value="Please enter login information" />
<text name="TenancyName" value="Tenancy name" />
<text name="UserNameOrEmail" value="User name or email" />
<text name="Password" value="Password" />
<text name="RememberMe" value="Remember me" />
<text name="LogIn" value="Log in" />
<text name="LoginFailed" value="Login failed!" />
<text name="LoginFailed" value="Błąd logowania!" />
<text name="NameSurname" value="Name surname" />
<text name="UserName" value="User name" />
<text name="Name" value="Name" />
@ -41,7 +41,7 @@
<text name="Logout" value="Logout" />
<text name="RegisterFormUserNameInvalidMessage">Please don't enter an email address for username.</text>
<text name="DatabaseConnectionString" value="Database connection string" />
<text name="Users" value="Users" />
<text name="Users" value="Użytkownicy" />
<text name="IsActive" value="Is active" />
<text name="FullName" value="Full name" />
<text name="CreateNewUser" value="Create new user" />
@ -57,7 +57,7 @@
<text name="Back">Back</text>
<text name="SuccessfullyRegistered">Successfully registered</text>
<text name="WaitingForEmailActivation">Your email address should be activated</text>
<text name="Roles">Roles</text>
<text name="Roles">Role</text>
<text name="DisplayName">Display Name</text>
<text name="Edit">Edit</text>
<text name="Delete">Delete</text>
@ -91,5 +91,7 @@
<text name="StartTyping">Start Typing</text>
<text name="Skins">Skins</text>
<text name="Settings">Settings</text>
<text name="CreateCompetition">Tworzenie konkursu</text>
<text name="SolveCompetition">Rozwiązywanie konkursu</text>
</texts>
</localizationDictionary>

View File

@ -27,6 +27,7 @@ namespace SystemKonkursow.EntityFrameworkCore.Seed
// Default tenant seed (in host database).
new DefaultTenantBuilder(context).Create();
new TenantRoleAndUserBuilder(context, 1).Create();
new UserBuilder(context).Create();
}
private static void WithDbContext<TDbContext>(IIocResolver iocResolver, Action<TDbContext> contextAction)

View File

@ -0,0 +1,101 @@
using Abp.Authorization.Roles;
using Abp.Authorization.Users;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using System.Collections.Generic;
using System.Linq;
using SystemKonkursow.Authorization;
using SystemKonkursow.Authorization.Roles;
using SystemKonkursow.Authorization.Users;
namespace SystemKonkursow.EntityFrameworkCore.Seed
{
public class UserBuilder
{
private readonly SystemKonkursowDbContext _context;
public UserBuilder(SystemKonkursowDbContext context)
{
_context = context;
}
public void Create()
{
if (_context.Roles.Count() > 2)
return;
Role organizerRole = CreateRole(StaticRoleNames.Host.Organizer, new List<string> {
PermissionNames.Pages_Create_Competition
//list permissions
});
CreateUser(new List<Role> { organizerRole }, "Jan", "Kowalski", "organizator", "organizator@example.com");
Role participantRole = CreateRole(StaticRoleNames.Host.Participant, new List<string> {
PermissionNames.Pages_Solve_Competition
//list permissions
});
CreateUser(new List<Role> { participantRole }, "Jerzy", "Nowak", "uczestnik", "uczestnik@example.com");
}
private Role CreateRole(string roleName, IList<string> permissionList)
{
var role = _context.Roles.IgnoreQueryFilters().FirstOrDefault(r => r.TenantId == null && r.Name == roleName);
if (role == null)
{
role = _context.Roles.Add(new Role(1, roleName, roleName) { IsStatic = true }).Entity;
_context.SaveChanges();
}
_context.Permissions.AddRange(
permissionList.Select(permission => new RolePermissionSetting
{
TenantId = 1,
Name = permission,
IsGranted = true,
RoleId = role.Id
})
);
_context.SaveChanges();
return role;
}
private void CreateUser(IEnumerable<Role> roles, string name, string surname, string userName, string emailAddress)
{
var user = _context.Users.IgnoreQueryFilters()
.FirstOrDefault(u => u.TenantId == 1 && u.UserName == userName);
if (null == user)
{
user = new User()
{
Name = name,
Surname = surname,
UserName = userName,
EmailAddress = emailAddress,
IsEmailConfirmed = true,
IsActive = true,
TenantId = 1,
};
user.SetNormalizedNames();
user.Password = new PasswordHasher<User>(new OptionsWrapper<PasswordHasherOptions>(new PasswordHasherOptions())).HashPassword(user, "123qwe");
_context.Users.Add(user);
_context.SaveChanges();
// Assign role to user
foreach (var role in roles)
{
if (role != null)
{
_context.UserRoles.Add(new UserRole(1, user.Id, role.Id));
_context.SaveChanges();
}
}
}
}
}
}