Skip to content
Snippets Groups Projects
Verified Commit 7bc7349b authored by Lukas Maximilian Kimpel's avatar Lukas Maximilian Kimpel
Browse files

Return true for successful request for register/resetpassword

parent 8529fe87
Branches
Tags
No related merge requests found
......@@ -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() {
......
......@@ -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();
});
......
......@@ -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();
});
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment