diff --git a/src/app/authentication.service.ts b/src/app/authentication.service.ts index 74f2dcd89beb17827807d9680afa55e0472d683c..7d987594c5e2240c1f0cb396dfd8ad6cbc0c3118 100644 --- a/src/app/authentication.service.ts +++ b/src/app/authentication.service.ts @@ -13,12 +13,15 @@ export class AuthenticationService { private readonly STORAGE_KEY: string = 'USER'; private user: User; private apiBaseUrl = 'https://arsnova-staging.mni.thm.de/api'; + private apiV2Url = 'https://arsnova-staging.mni.thm.de/v2'; private apiAuthUrl = '/auth'; private apiLoginUrl = '/login'; + private apiUserUrl = '/user'; + private apiRegisterUrl = '/register'; private apiRegisteredUrl = '/registered'; + private apiResetPasswordUrl = '/resetpassword'; private httpOptions = { - headers: new HttpHeaders({ - }) + headers: new HttpHeaders({}) }; constructor(private dataStoreService: DataStoreService, @@ -44,12 +47,22 @@ export class AuthenticationService { return this.http.post<ClientAuthentication>(connectionUrl, null, this.httpOptions); } - register(email: string, password: string): Observable<boolean> { - return of(true); + register(email: string, password: string): Observable<ClientAuthentication> { + const connectionUrl: string = this.apiBaseUrl + this.apiRegisterUrl; + + return this.http.post<ClientAuthentication>(connectionUrl, { + loginId: email, + password: password + }, this.httpOptions); } resetPassword(email: string): Observable<boolean> { - return of(true); + const connectionUrl: string = this.apiV2Url + this.apiUserUrl + email + this.apiResetPasswordUrl; + + return this.http.post<boolean>(connectionUrl, { + key: null, + password: null + }, this.httpOptions); } logout() { diff --git a/src/app/password-reset/password-reset.component.ts b/src/app/password-reset/password-reset.component.ts index 36e2a9c27d1fc815afe7a4ce21db4af225239a26..ec6b9b85b6d3ddf0d470db32a084771a142b7b30 100644 --- a/src/app/password-reset/password-reset.component.ts +++ b/src/app/password-reset/password-reset.component.ts @@ -38,12 +38,9 @@ export class PasswordResetComponent implements OnInit { if (!this.usernameFormControl.hasError('required') && !this.usernameFormControl.hasError('email')) { this.authenticationService.resetPassword(username).subscribe(result => { - if (result) { - this.notificationService.show('Password was reset. Please check your mail!'); - this.dialogRef.close(); - } else { - this.notificationService.show('Could not reset your password. Is your email address correct?'); - } + // ToDo: Check what /resetpassword returns and check for potential errors + this.notificationService.show('Password was reset. Please check your mail!'); + this.dialogRef.close(); }); } else { this.notificationService.show('Please fit the requirements shown above.'); diff --git a/src/app/register/register.component.ts b/src/app/register/register.component.ts index 85fd4fe2fc437f8913a98d6bf528128175e53dc4..854da7a19f4742daeadb2f768f64f9e75e36e58b 100644 --- a/src/app/register/register.component.ts +++ b/src/app/register/register.component.ts @@ -55,17 +55,14 @@ export class RegisterComponent implements OnInit { ngOnInit() { } - register(username: string, password1: string, password2: string): void { + register(username: string, password1: string): void { if (!this.usernameFormControl.hasError('required') && !this.usernameFormControl.hasError('email') && !this.password1FormControl.hasError('required') && !this.password2FormControl.hasError('required') && !this.password2FormControl.hasError('passwordIsEqual')) { this.authenticationService.register(username, password1).subscribe(result => { - if (result) { - this.notificationService.show('Successfully registered. Please check your mail!'); - this.dialogRef.close(); - } else { - this.notificationService.show('Oops! Something went wrong on our side...'); - } + // ToDo: Check what /api/register returns and check for potential errors + this.notificationService.show('Successfully registered. Please check your mail!'); + this.dialogRef.close(); }); } else { this.notificationService.show('Please fit the requirements shown above.');