Frontend #143

Merged
Rripped merged 11 commits from frontend into main 2022-05-08 08:44:39 +00:00
3 changed files with 30 additions and 13 deletions
Showing only changes of commit 55db2069f7 - Show all commits

View File

@ -77,7 +77,7 @@
type="password"
class="form-control"
name="passwordRepeat"
[(ngModel)]="form.password"
[(ngModel)]="form.passwordRepeat"
required
minlength="6"
#passwordRepeat="ngModel"
@ -88,6 +88,9 @@
</div>
</div>
</div>
<div class="alert-danger" *ngIf="checkPasswordFailed">
Password does not match, make sure it is the same!
</div>
<div class="form-group">
<button class="btn btn-primary btn-block">Sign Up</button>
</div>

View File

@ -11,4 +11,10 @@
.backgorund {
background-color: #181a1b;
color: white;
padding-top: 2vh;
}
.profile-img-card {
border-radius: 2%;
box-shadow: 0 0 0 500px #181a1b;
}

View File

@ -11,29 +11,37 @@ export class RegisterComponent {
form: any = {
email: null,
password: null,
passwordRepeat: null,
username: null,
};
isSuccessful = false;
isSignUpFailed = false;
errorMessage = '';
checkPasswordFailed = false;
/**
* @param {AuthService} privateauthService
* @param {Router} privaterouter
*/
constructor(private authService: AuthService, private router: Router) {}
onSubmit(): void {
const { email, username, password } = this.form;
this.authService.register(email, username, password).subscribe(
(data) => {
this.isSuccessful = true;
this.isSignUpFailed = false;
this.router.navigate(['/login']);
},
(err) => {
this.errorMessage = err.error.message;
this.isSignUpFailed = true;
}
);
if (this.form.password === this.form.passwordRepeat) {
this.checkPasswordFailed = false;
const { email, username, password } = this.form;
this.authService.register(email, username, password).subscribe(
(data) => {
this.isSuccessful = true;
this.isSignUpFailed = false;
this.router.navigate(['/login']);
},
(err) => {
this.errorMessage = err.error.message;
this.isSignUpFailed = true;
}
);
} else {
this.checkPasswordFailed = true;
}
}
}