diff --git a/src/app/authentication.service.ts b/src/app/authentication.service.ts index 7140fb6c010aaa32580c5678baa62e70d157067e..344a6562d14f931d8c211daded76d407e21a74ae 100644 --- a/src/app/authentication.service.ts +++ b/src/app/authentication.service.ts @@ -49,22 +49,26 @@ export class AuthenticationService { return this.checkLogin(this.http.post<ClientAuthentication>(connectionUrl, null, this.httpOptions), UserRole.PARTICIPANT); } - register(email: string, password: string): void { + register(email: string, password: string): Observable<boolean> { const connectionUrl: string = this.apiUrl.base + this.apiUrl.user + this.apiUrl.register; - this.http.post<ClientAuthentication>(connectionUrl, { + return this.http.post<boolean>(connectionUrl, { loginId: email, password: password - }, this.httpOptions); + }, this.httpOptions).map(() => { + return true; + }); } resetPassword(email: string): Observable<boolean> { const connectionUrl: string = this.apiUrl.v2 + this.apiUrl.user + email + this.apiUrl.resetPassword; - return this.http.post<boolean>(connectionUrl, { + return this.http.post(connectionUrl, { key: null, password: null - }, this.httpOptions); + }, this.httpOptions).map(() => { + return true; + }); } logout() { diff --git a/src/app/password-reset/password-reset.component.ts b/src/app/password-reset/password-reset.component.ts index ec6b9b85b6d3ddf0d470db32a084771a142b7b30..07a439cda34f9251667cee38f415c5acd45769c3 100644 --- a/src/app/password-reset/password-reset.component.ts +++ b/src/app/password-reset/password-reset.component.ts @@ -37,8 +37,7 @@ export class PasswordResetComponent implements OnInit { username = username.trim(); if (!this.usernameFormControl.hasError('required') && !this.usernameFormControl.hasError('email')) { - this.authenticationService.resetPassword(username).subscribe(result => { - // ToDo: Check what /resetpassword returns and check for potential errors + this.authenticationService.resetPassword(username).subscribe(() => { this.notificationService.show('Password was reset. Please check your mail!'); this.dialogRef.close(); }); diff --git a/src/app/register/register.component.ts b/src/app/register/register.component.ts index e754a9272f7a9fc8aba8f8097102cfa39a2b27d7..1416e8b1cdd4057429fc23d1a7d9082d2e72301c 100644 --- a/src/app/register/register.component.ts +++ b/src/app/register/register.component.ts @@ -59,9 +59,7 @@ export class RegisterComponent implements OnInit { if (!this.usernameFormControl.hasError('required') && !this.usernameFormControl.hasError('email') && !this.password1FormControl.hasError('required') && !this.password2FormControl.hasError('required') && !this.password2FormControl.hasError('passwordIsEqual')) { - // ToDo: Check return type of register route - this.authenticationService.register(username, password1).subscribe(result => { - // ToDo: Check what /api/register returns and check for potential errors + this.authenticationService.register(username, password1).subscribe(() => { this.notificationService.show('Successfully registered. Please check your mail!'); this.dialogRef.close(); });