Merge pull request 'Unbekannte Benutzer führen zu einem Fehler mit tracking id statt einer fehlermeldung #247' (#249) from #247 into 1.0.0
Reviewed-on: sh-edraft.de/kd_discord_bot#249 Reviewed-by: edraft-dev <dev.sven.heidemann@sh-edraft.de> Closes #247
This commit is contained in:
commit
54b0086a14
@ -71,7 +71,7 @@ class AuthController:
|
|||||||
@Route.post(f"{BasePath}/register")
|
@Route.post(f"{BasePath}/register")
|
||||||
async def register(self):
|
async def register(self):
|
||||||
dto: AuthUserDTO = JSONProcessor.process(AuthUserDTO, request.get_json(force=True, silent=True))
|
dto: AuthUserDTO = JSONProcessor.process(AuthUserDTO, request.get_json(force=True, silent=True))
|
||||||
await self._auth_service.add_auth_user(dto)
|
self._auth_service.add_auth_user(dto)
|
||||||
return "", 200
|
return "", 200
|
||||||
|
|
||||||
@Route.post(f"{BasePath}/register-by-id/<id>")
|
@Route.post(f"{BasePath}/register-by-id/<id>")
|
||||||
|
@ -80,6 +80,9 @@ class AuthService(AuthServiceABC):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _is_email_valid(email: str) -> bool:
|
def _is_email_valid(email: str) -> bool:
|
||||||
|
if email is None:
|
||||||
|
raise False
|
||||||
|
|
||||||
if re.fullmatch(_email_regex, email) is not None:
|
if re.fullmatch(_email_regex, email) is not None:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class QueryABC(ObjectType):
|
|||||||
return self._resolve_collection(collection, *args, **kwargs)
|
return self._resolve_collection(collection, *args, **kwargs)
|
||||||
|
|
||||||
self.set_field(f"{name}s", wrapper)
|
self.set_field(f"{name}s", wrapper)
|
||||||
self.set_field(f"{name}Count", lambda *args: get_collection(*args).count())
|
self.set_field(f"{name}Count", lambda *args: wrapper(*args).count())
|
||||||
|
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def _can_user_see_element(self, user: AuthUser, element, services: ServiceProviderABC) -> bool:
|
def _can_user_see_element(self, user: AuthUser, element, services: ServiceProviderABC) -> bool:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "kdb-web",
|
"name": "kdb-web",
|
||||||
"version": "1.0.0.rc1",
|
"version": "1.0.dev247",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"update-version": "ts-node-esm update-version.ts",
|
"update-version": "ts-node-esm update-version.ts",
|
||||||
|
@ -4,6 +4,7 @@ import { SoftwareVersion } from "src/app/models/config/software-version";
|
|||||||
import { GuiService } from "src/app/services/gui/gui.service";
|
import { GuiService } from "src/app/services/gui/gui.service";
|
||||||
import { SettingsService } from "src/app/services/settings/settings.service";
|
import { SettingsService } from "src/app/services/settings/settings.service";
|
||||||
import { SpinnerService } from "src/app/services/spinner/spinner.service";
|
import { SpinnerService } from "src/app/services/spinner/spinner.service";
|
||||||
|
import { throwError } from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-footer',
|
selector: 'app-footer',
|
||||||
@ -27,9 +28,9 @@ export class FooterComponent implements OnInit {
|
|||||||
|
|
||||||
this.spinnerService.showSpinner();
|
this.spinnerService.showSpinner();
|
||||||
this.guiService.getApiVersion()
|
this.guiService.getApiVersion()
|
||||||
.pipe(catchError(err => {
|
.pipe(catchError(error => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
throw err;
|
return throwError(() => error);
|
||||||
}))
|
}))
|
||||||
.subscribe(version => {
|
.subscribe(version => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
|
@ -7,6 +7,7 @@ import { AuthService } from 'src/app/services/auth/auth.service';
|
|||||||
import { SettingsService } from 'src/app/services/settings/settings.service';
|
import { SettingsService } from 'src/app/services/settings/settings.service';
|
||||||
import { SpinnerService } from 'src/app/services/spinner/spinner.service';
|
import { SpinnerService } from 'src/app/services/spinner/spinner.service';
|
||||||
import { ThemeService } from 'src/app/services/theme/theme.service';
|
import { ThemeService } from 'src/app/services/theme/theme.service';
|
||||||
|
import { throwError } from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-header',
|
selector: 'app-header',
|
||||||
@ -40,10 +41,10 @@ export class HeaderComponent implements OnInit {
|
|||||||
this.spinnerService.showSpinner();
|
this.spinnerService.showSpinner();
|
||||||
const mail = this.authService.getEMailFromDecodedToken(this.authService.getDecodedToken());
|
const mail = this.authService.getEMailFromDecodedToken(this.authService.getDecodedToken());
|
||||||
this.authService.getUserByEMail(mail ?? '')
|
this.authService.getUserByEMail(mail ?? '')
|
||||||
.pipe(catchError(err => {
|
.pipe(catchError(error => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
this.authService.logout();
|
this.authService.logout();
|
||||||
throw err;
|
return throwError(() => error);
|
||||||
}))
|
}))
|
||||||
.subscribe(user => {
|
.subscribe(user => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
|
@ -18,9 +18,9 @@ import { TranslateService } from "@ngx-translate/core";
|
|||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-auth-user',
|
selector: "app-auth-user",
|
||||||
templateUrl: './auth-user.component.html',
|
templateUrl: "./auth-user.component.html",
|
||||||
styleUrls: ['./auth-user.component.scss']
|
styleUrls: ["./auth-user.component.scss"]
|
||||||
})
|
})
|
||||||
export class AuthUserComponent implements OnInit {
|
export class AuthUserComponent implements OnInit {
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ export class AuthUserComponent implements OnInit {
|
|||||||
authRoles = [
|
authRoles = [
|
||||||
{ label: AuthRoles[AuthRoles.Normal].toString(), value: AuthRoles.Normal },
|
{ label: AuthRoles[AuthRoles.Normal].toString(), value: AuthRoles.Normal },
|
||||||
{ label: AuthRoles[AuthRoles.Admin].toString(), value: AuthRoles.Admin }
|
{ label: AuthRoles[AuthRoles.Admin].toString(), value: AuthRoles.Admin }
|
||||||
]
|
];
|
||||||
|
|
||||||
newUserTemplate: AuthUserDTO = {
|
newUserTemplate: AuthUserDTO = {
|
||||||
id: 0,
|
id: 0,
|
||||||
@ -71,10 +71,11 @@ export class AuthUserComponent implements OnInit {
|
|||||||
private confirmDialog: ConfirmationDialogService,
|
private confirmDialog: ConfirmationDialogService,
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
private translate: TranslateService
|
private translate: TranslateService
|
||||||
) { }
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.loggedInUserEMail = this.authService.getEMailFromDecodedToken(this.authService.getDecodedToken()) ?? '';
|
this.loggedInUserEMail = this.authService.getEMailFromDecodedToken(this.authService.getDecodedToken()) ?? "";
|
||||||
this.searchCriterions = {
|
this.searchCriterions = {
|
||||||
firstName: null,
|
firstName: null,
|
||||||
lastName: null,
|
lastName: null,
|
||||||
@ -92,10 +93,10 @@ export class AuthUserComponent implements OnInit {
|
|||||||
|
|
||||||
setFilterForm() {
|
setFilterForm() {
|
||||||
this.filterForm = this.fb.group({
|
this.filterForm = this.fb.group({
|
||||||
firstName: [''],
|
firstName: [""],
|
||||||
lastName: [''],
|
lastName: [""],
|
||||||
email: [''],
|
email: [""],
|
||||||
authRole: ['']
|
authRole: [""]
|
||||||
});
|
});
|
||||||
|
|
||||||
this.filterForm.valueChanges.pipe(
|
this.filterForm.valueChanges.pipe(
|
||||||
@ -152,14 +153,14 @@ export class AuthUserComponent implements OnInit {
|
|||||||
if (event.first != null && event.rows != null)
|
if (event.first != null && event.rows != null)
|
||||||
this.searchCriterions.pageIndex = event.first / event.rows;
|
this.searchCriterions.pageIndex = event.first / event.rows;
|
||||||
this.searchCriterions.sortColumn = event.sortField ?? null;
|
this.searchCriterions.sortColumn = event.sortField ?? null;
|
||||||
this.searchCriterions.sortDirection = event.sortOrder === 1 ? 'asc' : event.sortOrder === -1 ? 'desc' : 'asc';
|
this.searchCriterions.sortDirection = event.sortOrder === 1 ? "asc" : event.sortOrder === -1 ? "desc" : "asc";
|
||||||
|
|
||||||
if (event.filters) {
|
if (event.filters) {
|
||||||
// + "" => convert to string
|
// + "" => convert to string
|
||||||
this.searchCriterions.firstName = event.filters['firstName'] ? event.filters['firstName'] + "" : null;
|
this.searchCriterions.firstName = event.filters["firstName"] ? event.filters["firstName"] + "" : null;
|
||||||
this.searchCriterions.lastName = event.filters['lastName'] ? event.filters['lastName'] + "" : null;
|
this.searchCriterions.lastName = event.filters["lastName"] ? event.filters["lastName"] + "" : null;
|
||||||
this.searchCriterions.email = event.filters['email'] ? event.filters['email'] + "" : null;
|
this.searchCriterions.email = event.filters["email"] ? event.filters["email"] + "" : null;
|
||||||
this.searchCriterions.authRole = event.filters['authRole'] ? +event.filters['authRole'] : null;
|
this.searchCriterions.authRole = event.filters["authRole"] ? +event.filters["authRole"] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loadNextPage();
|
this.loadNextPage();
|
||||||
@ -172,9 +173,9 @@ export class AuthUserComponent implements OnInit {
|
|||||||
initUserList(): void {
|
initUserList(): void {
|
||||||
this.spinnerService.showSpinner();
|
this.spinnerService.showSpinner();
|
||||||
this.authService.getAllUsers()
|
this.authService.getAllUsers()
|
||||||
.pipe(catchError(err => {
|
.pipe(catchError(error => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
throw err;
|
return throwError(() => error);
|
||||||
}))
|
}))
|
||||||
.subscribe(users => {
|
.subscribe(users => {
|
||||||
this.users = users;
|
this.users = users;
|
||||||
@ -226,22 +227,22 @@ export class AuthUserComponent implements OnInit {
|
|||||||
|
|
||||||
if (err.errorCode === ServiceErrorCode.InvalidData && err.message === RegisterErrorMessages.InvalidEMail) {
|
if (err.errorCode === ServiceErrorCode.InvalidData && err.message === RegisterErrorMessages.InvalidEMail) {
|
||||||
this.isEMailInvalid = true;
|
this.isEMailInvalid = true;
|
||||||
this.toastService.error(this.translate.instant('admin.auth_users.message.invalid_email'), this.translate.instant('admin.auth_users.message.invalid_email_d', { email: newUser.email }));
|
this.toastService.error(this.translate.instant("admin.auth_users.message.invalid_email"), this.translate.instant("admin.auth_users.message.invalid_email_d", { email: newUser.email }));
|
||||||
} else if (err.errorCode === ServiceErrorCode.InvalidUser && err.message === RegisterErrorMessages.UserAlreadyExists) {
|
} else if (err.errorCode === ServiceErrorCode.InvalidUser && err.message === RegisterErrorMessages.UserAlreadyExists) {
|
||||||
this.isEMailInvalid = true;
|
this.isEMailInvalid = true;
|
||||||
this.toastService.error(this.translate.instant('admin.auth_users.message.user_already_exists'), this.translate.instant('admin.auth_users.message.user_already_exists_d', { email: newUser.email }));
|
this.toastService.error(this.translate.instant("admin.auth_users.message.user_already_exists"), this.translate.instant("admin.auth_users.message.user_already_exists_d", { email: newUser.email }));
|
||||||
}
|
}
|
||||||
error.error = null;
|
error.error = null;
|
||||||
table.initRowEdit(newUser);
|
table.initRowEdit(newUser);
|
||||||
}
|
}
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
|
|
||||||
throw error;
|
return throwError(() => error);
|
||||||
}))
|
}))
|
||||||
.subscribe(_ => {
|
.subscribe(_ => {
|
||||||
this.initUserList();
|
this.initUserList();
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
this.toastService.success(this.translate.instant('admin.auth_users.message.user_added'), this.translate.instant('admin.auth_users.message.user_added_d', { email: newUser.email }));
|
this.toastService.success(this.translate.instant("admin.auth_users.message.user_added"), this.translate.instant("admin.auth_users.message.user_added_d", { email: newUser.email }));
|
||||||
this.isEditingNew = false;
|
this.isEditingNew = false;
|
||||||
});
|
});
|
||||||
this.triggerUserChangeDetection();
|
this.triggerUserChangeDetection();
|
||||||
@ -253,16 +254,16 @@ export class AuthUserComponent implements OnInit {
|
|||||||
authUserDTO: oldUser,
|
authUserDTO: oldUser,
|
||||||
newAuthUserDTO: newUser,
|
newAuthUserDTO: newUser,
|
||||||
changePassword: newUser.password != ""
|
changePassword: newUser.password != ""
|
||||||
}).pipe(catchError(err => {
|
}).pipe(catchError(error => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
this.toastService.error(this.translate.instant('admin.auth_users.message.user_change_failed'), this.translate.instant('admin.auth_users.message.user_change_failed_d', { email: newUser.email }));
|
this.toastService.error(this.translate.instant("admin.auth_users.message.user_change_failed"), this.translate.instant("admin.auth_users.message.user_change_failed_d", { email: newUser.email }));
|
||||||
this.initUserList();
|
this.initUserList();
|
||||||
throw err;
|
return throwError(() => error);
|
||||||
}))
|
}))
|
||||||
.subscribe(_ => {
|
.subscribe(_ => {
|
||||||
this.initUserList();
|
this.initUserList();
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
this.toastService.success(this.translate.instant('admin.auth_users.message.user_changed'), this.translate.instant('admin.auth_users.message.user_changed_d', { email: newUser.email }));
|
this.toastService.success(this.translate.instant("admin.auth_users.message.user_changed"), this.translate.instant("admin.auth_users.message.user_changed_d", { email: newUser.email }));
|
||||||
});
|
});
|
||||||
this.triggerUserChangeDetection();
|
this.triggerUserChangeDetection();
|
||||||
}
|
}
|
||||||
@ -288,30 +289,32 @@ export class AuthUserComponent implements OnInit {
|
|||||||
|
|
||||||
deleteUser(user: AuthUserDTO) {
|
deleteUser(user: AuthUserDTO) {
|
||||||
if (user.email == this.loggedInUserEMail) {
|
if (user.email == this.loggedInUserEMail) {
|
||||||
this.toastService.error(this.translate.instant('admin.auth_users.message.cannot_delete_user'), this.translate.instant('admin.auth_users.message.logon_with_another_user'));
|
this.toastService.error(this.translate.instant("admin.auth_users.message.cannot_delete_user"), this.translate.instant("admin.auth_users.message.logon_with_another_user"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.confirmDialog.confirmDialog(
|
this.confirmDialog.confirmDialog(
|
||||||
this.translate.instant('admin.auth_users.message.user_delete'), this.translate.instant('admin.auth_users.message.user_delete_q', { email: user.email }),
|
this.translate.instant("admin.auth_users.message.user_delete"), this.translate.instant("admin.auth_users.message.user_delete_q", { email: user.email }),
|
||||||
() => {
|
() => {
|
||||||
this.spinnerService.showSpinner();
|
this.spinnerService.showSpinner();
|
||||||
this.authService.deleteUserByMail(user.email ?? '')
|
this.authService.deleteUserByMail(user.email ?? "")
|
||||||
.pipe(catchError(err => {
|
.pipe(catchError(error => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
throw err;
|
return throwError(() => error);
|
||||||
}))
|
}))
|
||||||
.subscribe(_ => {
|
.subscribe(_ => {
|
||||||
this.initUserList();
|
this.initUserList();
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
this.toastService.success(this.translate.instant('admin.auth_users.message.user_deleted'), this.translate.instant('admin.auth_users.message.user_deleted_d', { email: user.email }));
|
this.toastService.success(this.translate.instant("admin.auth_users.message.user_deleted"), this.translate.instant("admin.auth_users.message.user_deleted_d", { email: user.email }));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
addUser(table: Table) {
|
addUser(table: Table) {
|
||||||
const newUser = JSON.parse(JSON.stringify(this.newUserTemplate));
|
const newUser = JSON.parse(JSON.stringify(this.newUserTemplate));
|
||||||
newUser.id = Math.max.apply(Math, this.users.map(u => { return u.id ?? 0; })) + 1;
|
newUser.id = Math.max.apply(Math, this.users.map(u => {
|
||||||
|
return u.id ?? 0;
|
||||||
|
})) + 1;
|
||||||
|
|
||||||
this.users.push(newUser);
|
this.users.push(newUser);
|
||||||
this.triggerUserChangeDetection();
|
this.triggerUserChangeDetection();
|
||||||
|
@ -10,6 +10,7 @@ import { GuiService } from 'src/app/services/gui/gui.service';
|
|||||||
import { SettingsService } from 'src/app/services/settings/settings.service';
|
import { SettingsService } from 'src/app/services/settings/settings.service';
|
||||||
import { SpinnerService } from 'src/app/services/spinner/spinner.service';
|
import { SpinnerService } from 'src/app/services/spinner/spinner.service';
|
||||||
import { ToastService } from 'src/app/services/toast/toast.service';
|
import { ToastService } from 'src/app/services/toast/toast.service';
|
||||||
|
import { throwError } from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-settings',
|
selector: 'app-settings',
|
||||||
@ -50,9 +51,9 @@ export class SettingsComponent implements OnInit {
|
|||||||
this.initForms();
|
this.initForms();
|
||||||
|
|
||||||
this.guiService.getSettings()
|
this.guiService.getSettings()
|
||||||
.pipe(catchError(err => {
|
.pipe(catchError(error => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
throw err;
|
return throwError(() => error);
|
||||||
}))
|
}))
|
||||||
.subscribe(settings => {
|
.subscribe(settings => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
@ -109,7 +110,7 @@ export class SettingsComponent implements OnInit {
|
|||||||
|
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
this.toastService.error(header, message);
|
this.toastService.error(header, message);
|
||||||
throw error;
|
return throwError(() => error);
|
||||||
}))
|
}))
|
||||||
.subscribe(res => {
|
.subscribe(res => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
|
@ -7,6 +7,7 @@ import { ResetPasswordDTO } from 'src/app/models/auth/reset-password.dto';
|
|||||||
import { AuthService } from 'src/app/services/auth/auth.service';
|
import { AuthService } from 'src/app/services/auth/auth.service';
|
||||||
import { SpinnerService } from 'src/app/services/spinner/spinner.service';
|
import { SpinnerService } from 'src/app/services/spinner/spinner.service';
|
||||||
import { ToastService } from 'src/app/services/toast/toast.service';
|
import { ToastService } from 'src/app/services/toast/toast.service';
|
||||||
|
import { throwError } from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-forget-password',
|
selector: 'app-forget-password',
|
||||||
@ -77,9 +78,9 @@ export class ForgetPasswordComponent implements OnInit {
|
|||||||
|
|
||||||
this.spinnerService.showSpinner();
|
this.spinnerService.showSpinner();
|
||||||
this.authService.forgotPassword(this.emailForm.value.email)
|
this.authService.forgotPassword(this.emailForm.value.email)
|
||||||
.pipe(catchError(err => {
|
.pipe(catchError(error => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
throw err;
|
return throwError(() => error);
|
||||||
})).subscribe(res => {
|
})).subscribe(res => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
this.ready = true;
|
this.ready = true;
|
||||||
@ -93,10 +94,10 @@ export class ForgetPasswordComponent implements OnInit {
|
|||||||
this.resetPasswordId = id;
|
this.resetPasswordId = id;
|
||||||
this.spinnerService.showSpinner();
|
this.spinnerService.showSpinner();
|
||||||
this.authService.getEMailFromforgotPasswordId(id)
|
this.authService.getEMailFromforgotPasswordId(id)
|
||||||
.pipe(catchError(err => {
|
.pipe(catchError(error => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
this.router.navigate(['/auth/forgot-password']);
|
this.router.navigate(['/auth/forgot-password']);
|
||||||
throw err;
|
return throwError(() => error);
|
||||||
})).subscribe(email => {
|
})).subscribe(email => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
if (email) {
|
if (email) {
|
||||||
@ -125,7 +126,7 @@ export class ForgetPasswordComponent implements OnInit {
|
|||||||
.pipe(catchError(error => {
|
.pipe(catchError(error => {
|
||||||
this.router.navigate(['/auth/login']);
|
this.router.navigate(['/auth/login']);
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
throw error;
|
return throwError(() => error);
|
||||||
}))
|
}))
|
||||||
.subscribe(resp => {
|
.subscribe(resp => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
|
@ -146,17 +146,20 @@ export class LoginComponent implements OnInit {
|
|||||||
if (err.errorCode === ServiceErrorCode.InvalidData && err.message === AuthErrorMessages.UserIsEmpty) {
|
if (err.errorCode === ServiceErrorCode.InvalidData && err.message === AuthErrorMessages.UserIsEmpty) {
|
||||||
this.authUserAtrErrors.email.required = true;
|
this.authUserAtrErrors.email.required = true;
|
||||||
this.authUserAtrErrors.password.required = true;
|
this.authUserAtrErrors.password.required = true;
|
||||||
|
error.error = null;
|
||||||
} else if (err.errorCode === ServiceErrorCode.InvalidUser && err.message === AuthErrorMessages.UserNotFound) {
|
} else if (err.errorCode === ServiceErrorCode.InvalidUser && err.message === AuthErrorMessages.UserNotFound) {
|
||||||
this.authUserAtrErrors.email.wrongData = true;
|
this.authUserAtrErrors.email.wrongData = true;
|
||||||
|
error.error = null;
|
||||||
} else if (err.errorCode === ServiceErrorCode.InvalidUser && err.message === AuthErrorMessages.WrongPassword) {
|
} else if (err.errorCode === ServiceErrorCode.InvalidUser && err.message === AuthErrorMessages.WrongPassword) {
|
||||||
this.authUserAtrErrors.password.wrongData = true;
|
this.authUserAtrErrors.password.wrongData = true;
|
||||||
|
error.error = null;
|
||||||
} else if (err.errorCode === ServiceErrorCode.InvalidUser && err.message === AuthErrorMessages.EMailNotConfirmed) {
|
} else if (err.errorCode === ServiceErrorCode.InvalidUser && err.message === AuthErrorMessages.EMailNotConfirmed) {
|
||||||
this.authUserAtrErrors.email.notConfirmed = true;
|
this.authUserAtrErrors.email.notConfirmed = true;
|
||||||
|
error.error = null;
|
||||||
}
|
}
|
||||||
error.error = null;
|
|
||||||
}
|
}
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
throw error;
|
return throwError(() => error);
|
||||||
}))
|
}))
|
||||||
.subscribe(token => {
|
.subscribe(token => {
|
||||||
this.authService.saveToken(token);
|
this.authService.saveToken(token);
|
||||||
|
@ -127,7 +127,7 @@ export class RegistrationComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
throw error;
|
return throwError(() => error);
|
||||||
}))
|
}))
|
||||||
.subscribe(resp => {
|
.subscribe(resp => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
@ -143,7 +143,7 @@ export class RegistrationComponent implements OnInit {
|
|||||||
.pipe(catchError(error => {
|
.pipe(catchError(error => {
|
||||||
this.router.navigate(["/auth/login"]);
|
this.router.navigate(["/auth/login"]);
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
throw error;
|
return throwError(() => error);
|
||||||
}))
|
}))
|
||||||
.subscribe(resp => {
|
.subscribe(resp => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
|
@ -10,6 +10,7 @@ import { ServiceErrorCode } from 'src/app/models/error/service-error-code.enum';
|
|||||||
import { AuthService } from 'src/app/services/auth/auth.service';
|
import { AuthService } from 'src/app/services/auth/auth.service';
|
||||||
import { SpinnerService } from 'src/app/services/spinner/spinner.service';
|
import { SpinnerService } from 'src/app/services/spinner/spinner.service';
|
||||||
import { ToastService } from 'src/app/services/toast/toast.service';
|
import { ToastService } from 'src/app/services/toast/toast.service';
|
||||||
|
import { throwError } from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-change-password',
|
selector: 'app-change-password',
|
||||||
@ -95,7 +96,8 @@ export class ChangePasswordComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
this.toastService.error(this.translate.instant('view.change_password.message.error'), this.translate.instant('view.change_password.message.password_cannot_be_changed'));
|
this.toastService.error(this.translate.instant('view.change_password.message.error'), this.translate.instant('view.change_password.message.password_cannot_be_changed'));
|
||||||
throw error;
|
|
||||||
|
return throwError(() => error);
|
||||||
}))
|
}))
|
||||||
.subscribe(resp => {
|
.subscribe(resp => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
|
@ -1,22 +1,23 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from "@angular/core";
|
||||||
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
|
import { FormBuilder, FormControl, FormGroup, Validators } from "@angular/forms";
|
||||||
import { Router } from '@angular/router';
|
import { Router } from "@angular/router";
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from "@ngx-translate/core";
|
||||||
import { catchError } from 'rxjs/operators';
|
import { catchError } from "rxjs/operators";
|
||||||
import { AuthErrorMessages } from 'src/app/models/auth/auth-error-messages.enum';
|
import { AuthErrorMessages } from "src/app/models/auth/auth-error-messages.enum";
|
||||||
import { AuthUserDTO } from 'src/app/models/auth/auth-user.dto';
|
import { AuthUserDTO } from "src/app/models/auth/auth-user.dto";
|
||||||
import { UpdateUserDTO } from 'src/app/models/auth/update-user.dto';
|
import { UpdateUserDTO } from "src/app/models/auth/update-user.dto";
|
||||||
import { ErrorDTO } from 'src/app/models/error/error-dto';
|
import { ErrorDTO } from "src/app/models/error/error-dto";
|
||||||
import { ServiceErrorCode } from 'src/app/models/error/service-error-code.enum';
|
import { ServiceErrorCode } from "src/app/models/error/service-error-code.enum";
|
||||||
import { AuthService } from 'src/app/services/auth/auth.service';
|
import { AuthService } from "src/app/services/auth/auth.service";
|
||||||
import { SpinnerService } from 'src/app/services/spinner/spinner.service';
|
import { SpinnerService } from "src/app/services/spinner/spinner.service";
|
||||||
import { ThemeService } from 'src/app/services/theme/theme.service';
|
import { ThemeService } from "src/app/services/theme/theme.service";
|
||||||
import { ToastService } from 'src/app/services/toast/toast.service';
|
import { ToastService } from "src/app/services/toast/toast.service";
|
||||||
|
import { throwError } from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-user-settings',
|
selector: "app-user-settings",
|
||||||
templateUrl: './user-settings.component.html',
|
templateUrl: "./user-settings.component.html",
|
||||||
styleUrls: ['./user-settings.component.scss']
|
styleUrls: ["./user-settings.component.scss"]
|
||||||
})
|
})
|
||||||
export class UserSettingsComponent implements OnInit {
|
export class UserSettingsComponent implements OnInit {
|
||||||
settingsForm!: FormGroup<{
|
settingsForm!: FormGroup<{
|
||||||
@ -42,7 +43,8 @@ export class UserSettingsComponent implements OnInit {
|
|||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
private themeService: ThemeService,
|
private themeService: ThemeService,
|
||||||
private translaste: TranslateService
|
private translaste: TranslateService
|
||||||
) { }
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.initForms();
|
this.initForms();
|
||||||
@ -51,10 +53,10 @@ export class UserSettingsComponent implements OnInit {
|
|||||||
|
|
||||||
initForms(): void {
|
initForms(): void {
|
||||||
this.settingsForm = this.formBuilder.group({
|
this.settingsForm = this.formBuilder.group({
|
||||||
firstName: ['', [Validators.required]],
|
firstName: ["", [Validators.required]],
|
||||||
lastName: ['', [Validators.required]],
|
lastName: ["", [Validators.required]],
|
||||||
email: ['', [Validators.required, Validators.email]],
|
email: ["", [Validators.required, Validators.email]],
|
||||||
password: ['', [Validators.required, Validators.minLength(8)]]
|
password: ["", [Validators.required, Validators.minLength(8)]]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,14 +75,14 @@ export class UserSettingsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.authService.findUserByEMail(mail)
|
this.authService.findUserByEMail(mail)
|
||||||
.pipe(catchError(err => {
|
.pipe(catchError(error => {
|
||||||
this.toastService.error(this.translaste.instant('view.user_settings.message.user_not_found'), this.translaste.instant('view.user_settings.message.user_not_found_d'));
|
this.toastService.error(this.translaste.instant("view.user_settings.message.user_not_found"), this.translaste.instant("view.user_settings.message.user_not_found_d"));
|
||||||
this.authService.logout();
|
this.authService.logout();
|
||||||
throw err;
|
return throwError(() => error);
|
||||||
}))
|
}))
|
||||||
.subscribe(user => {
|
.subscribe(user => {
|
||||||
if (!user) {
|
if (!user) {
|
||||||
this.toastService.error(this.translaste.instant('view.user_settings.message.user_not_found'), this.translaste.instant('view.user_settings.message.user_not_found_d'));
|
this.toastService.error(this.translaste.instant("view.user_settings.message.user_not_found"), this.translaste.instant("view.user_settings.message.user_not_found_d"));
|
||||||
this.authService.logout();
|
this.authService.logout();
|
||||||
}
|
}
|
||||||
this.authUser = user;
|
this.authUser = user;
|
||||||
@ -122,27 +124,27 @@ export class UserSettingsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
this.toastService.error(this.translaste.instant('view.user_settings.message.error'), this.translaste.instant('view.user_settings.message.could_not_change_settings'));
|
this.toastService.error(this.translaste.instant("view.user_settings.message.error"), this.translaste.instant("view.user_settings.message.could_not_change_settings"));
|
||||||
throw error;
|
return throwError(() => error);
|
||||||
}))
|
}))
|
||||||
.subscribe(resp => {
|
.subscribe(resp => {
|
||||||
updateUserDTO.newAuthUserDTO.password = updateUserDTO.authUserDTO.password;
|
updateUserDTO.newAuthUserDTO.password = updateUserDTO.authUserDTO.password;
|
||||||
this.authService.login(updateUserDTO.newAuthUserDTO)
|
this.authService.login(updateUserDTO.newAuthUserDTO)
|
||||||
.pipe(catchError(err => {
|
.pipe(catchError(error => {
|
||||||
this.router.navigate(['/auth/login']);
|
this.router.navigate(["/auth/login"]);
|
||||||
throw err;
|
return throwError(() => error);
|
||||||
}))
|
}))
|
||||||
.subscribe(token => {
|
.subscribe(token => {
|
||||||
this.spinnerService.hideSpinner();
|
this.spinnerService.hideSpinner();
|
||||||
if (token) {
|
if (token) {
|
||||||
this.toastService.success(this.translaste.instant('view.user_settings.message.success'), this.translaste.instant('view.user_settings.message.changed_settings'));
|
this.toastService.success(this.translaste.instant("view.user_settings.message.success"), this.translaste.instant("view.user_settings.message.changed_settings"));
|
||||||
this.authService.saveToken(token);
|
this.authService.saveToken(token);
|
||||||
this.themeService.loadTheme();
|
this.themeService.loadTheme();
|
||||||
this.themeService.loadMenu();
|
this.themeService.loadMenu();
|
||||||
this.load();
|
this.load();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
this.router.navigate(['/auth/login']);
|
this.router.navigate(["/auth/login"]);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,7 @@ import { HttpClient, HttpHeaders } from "@angular/common/http";
|
|||||||
import { Injectable } from "@angular/core";
|
import { Injectable } from "@angular/core";
|
||||||
import { Router } from "@angular/router";
|
import { Router } from "@angular/router";
|
||||||
import { JwtHelperService } from "@auth0/angular-jwt";
|
import { JwtHelperService } from "@auth0/angular-jwt";
|
||||||
import { firstValueFrom, Observable, Subject, Subscription } from "rxjs";
|
import { firstValueFrom, Observable, Subject, Subscription, throwError } from "rxjs";
|
||||||
import { catchError } from "rxjs/operators";
|
import { catchError } from "rxjs/operators";
|
||||||
import { AdminUpdateUserDTO } from "src/app/models/auth/admin-update-user.dto";
|
import { AdminUpdateUserDTO } from "src/app/models/auth/admin-update-user.dto";
|
||||||
import { AuthRoles } from "src/app/models/auth/auth-roles.enum";
|
import { AuthRoles } from "src/app/models/auth/auth-roles.enum";
|
||||||
@ -231,7 +231,7 @@ export class AuthService {
|
|||||||
this.isLoggedIn$.next(false);
|
this.isLoggedIn$.next(false);
|
||||||
localStorage.removeItem("rjwt");
|
localStorage.removeItem("rjwt");
|
||||||
this.router.navigate(["/auth/login"]);
|
this.router.navigate(["/auth/login"]);
|
||||||
throw error;
|
return throwError(() => error);
|
||||||
})).subscribe(() => {
|
})).subscribe(() => {
|
||||||
this.isLoggedIn$.next(false);
|
this.isLoggedIn$.next(false);
|
||||||
localStorage.removeItem("jwt");
|
localStorage.removeItem("jwt");
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"WebVersion": {
|
"WebVersion": {
|
||||||
"Major": "1",
|
"Major": "1",
|
||||||
"Minor": "0",
|
"Minor": "0",
|
||||||
"Micro": "0.rc1"
|
"Micro": "dev247"
|
||||||
},
|
},
|
||||||
"Themes": [
|
"Themes": [
|
||||||
{
|
{
|
||||||
|
@ -518,6 +518,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.icon-btn {
|
.icon-btn {
|
||||||
|
.p-button-label {
|
||||||
|
transition-duration: unset !important;
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: transparent !important;
|
background-color: transparent !important;
|
||||||
color: $primaryHeaderColor !important;
|
color: $primaryHeaderColor !important;
|
||||||
|
@ -9,7 +9,7 @@ function Main(): void {
|
|||||||
setVersion(version);
|
setVersion(version);
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
throw err;
|
throwError(() => err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ async function setVersion(version: SoftwareVersion) {
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
fs.readFile(jsonFilePath, "utf8", (err: Error, data: string) => {
|
fs.readFile(jsonFilePath, "utf8", (err: Error, data: string) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throwError(() => err);
|
||||||
}
|
}
|
||||||
const settings: Appsettings = JSON.parse(data);
|
const settings: Appsettings = JSON.parse(data);
|
||||||
settings.WebVersion = version;
|
settings.WebVersion = version;
|
||||||
@ -59,7 +59,7 @@ async function setVersion(version: SoftwareVersion) {
|
|||||||
});
|
});
|
||||||
fs.readFile('./package.json', "utf8", (err: Error, data: string) => {
|
fs.readFile('./package.json', "utf8", (err: Error, data: string) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throwError(() => err);
|
||||||
}
|
}
|
||||||
const settings = JSON.parse(data);
|
const settings = JSON.parse(data);
|
||||||
settings.version = version.getVersionString();
|
settings.version = version.getVersionString();
|
||||||
|
Loading…
Reference in New Issue
Block a user