SES-114 Adder Errors to register view and user can no longer register with two different passwords
This commit is contained in:
parent
9826e57e7f
commit
004619d6dd
@ -6,7 +6,6 @@ import {Subscription} from 'rxjs';
|
||||
import {ErrorResponse} from '../../../types/ErrorResponse';
|
||||
import {UserRegisterViewModel} from '../../../types/viewmodels/user-viewmodels/UserRegisterViewModel';
|
||||
import {HttpErrorResponse} from '@angular/common/http';
|
||||
import {type} from 'os';
|
||||
|
||||
@Component({
|
||||
selector: 'app-registration',
|
||||
@ -36,27 +35,33 @@ export class RegistrationComponent implements OnDestroy {
|
||||
}
|
||||
|
||||
Register() {
|
||||
const userRegisterModel = new class implements UserRegisterViewModel {
|
||||
password: string;
|
||||
username: string;
|
||||
};
|
||||
if (this.signUpFormGroup.valid) {
|
||||
const userRegisterModel = new class implements UserRegisterViewModel {
|
||||
password: string;
|
||||
username: string;
|
||||
};
|
||||
|
||||
userRegisterModel.username = this.signUpFormGroup.get('newAccount').value['username'];
|
||||
userRegisterModel.password = this.signUpFormGroup.get('newAccount').value['password'];
|
||||
userRegisterModel.username = this.signUpFormGroup.get('newAccount').value['username'];
|
||||
userRegisterModel.password = this.signUpFormGroup.get('newAccount').value['password'];
|
||||
|
||||
this.allSubscriptions.add(
|
||||
this.userService.registerUser(userRegisterModel).subscribe(
|
||||
() => {
|
||||
this.router.navigate(['login']);
|
||||
},
|
||||
(error: ErrorResponse | HttpErrorResponse) => {
|
||||
if (error instanceof HttpErrorResponse) {
|
||||
error = error.error as ErrorResponse;
|
||||
this.allSubscriptions.add(
|
||||
this.userService.registerUser(userRegisterModel).subscribe(
|
||||
() => {
|
||||
this.router.navigate(['login']);
|
||||
},
|
||||
(error: ErrorResponse | HttpErrorResponse) => {
|
||||
if (error instanceof HttpErrorResponse) {
|
||||
error = error.error as ErrorResponse;
|
||||
}
|
||||
this.apiError = true;
|
||||
this.apiErrorMessage = error.message;
|
||||
}
|
||||
this.apiError = true;
|
||||
this.apiErrorMessage = error.message;
|
||||
}
|
||||
));
|
||||
));
|
||||
} else {
|
||||
this.signUpFormGroup.get('newAccount').get('username').markAsTouched();
|
||||
this.signUpFormGroup.get('newAccount').get('password').markAsTouched();
|
||||
this.signUpFormGroup.get('newAccount').get('confirmPassword').markAsTouched();
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
Loading…
Reference in New Issue
Block a user