diff --git a/frontend/src/app/components/auth/login/login.component.ts b/frontend/src/app/components/auth/login/login.component.ts index 044cff9..8dc5deb 100644 --- a/frontend/src/app/components/auth/login/login.component.ts +++ b/frontend/src/app/components/auth/login/login.component.ts @@ -40,7 +40,7 @@ export class LoginComponent { password: this.authData.password, }; try { - await this.authService.login(body); + await this.authService.login(body, this.authData.checkbox); ngForm.resetForm(); this.router.navigate(['/browse/']); this.errorService.clearError(); diff --git a/frontend/src/app/components/auth/register/register.component.html b/frontend/src/app/components/auth/register/register.component.html index b1b5c16..55366a1 100644 --- a/frontend/src/app/components/auth/register/register.component.html +++ b/frontend/src/app/components/auth/register/register.component.html @@ -37,7 +37,9 @@ } @else { @if (mail.touched && authData.mail.length > 0 && !isUserEmailValid(authData.mail.toLowerCase())) {
This is not a valid email format
- }} + }} @if ((errorService.error$ | async)) { +{{ errorService.error$ | async }}
+ } { @@ -34,11 +42,25 @@ export class RegisterComponent { return emailRegex.test(emailValue); } - onSubmit(ngForm: NgForm) { + async onSubmit(ngForm: NgForm) { if (ngForm.submitted && ngForm.form.valid) { - console.log(this.authData); - ngForm.form.reset(); - this.registrationSuccess = true; + const body = { + email: this.authData.mail, + username: this.authData.mail.split('@')[0], + password: this.authData.password, + }; + try { + await this.authService.register(body); + ngForm.resetForm(); + this.registrationSuccess = true; + this.errorService.clearError(); + } catch (error) { + if (error instanceof HttpErrorResponse) { + this.errorService.setError(error.error.detail); + } else { + this.errorService.setError('An unknown error has occurred.'); + } + } } } } diff --git a/frontend/src/app/components/home/browse/browse.component.scss b/frontend/src/app/components/home/browse/browse.component.scss index e2a2fc4..c9f5d1d 100644 --- a/frontend/src/app/components/home/browse/browse.component.scss +++ b/frontend/src/app/components/home/browse/browse.component.scss @@ -4,6 +4,7 @@ section { height: 100vh; width: 100vw; background-color: $black; + overflow: hidden; } .video-overlay { diff --git a/frontend/src/app/services/auth.service.ts b/frontend/src/app/services/auth.service.ts index 18ba4dc..669facb 100644 --- a/frontend/src/app/services/auth.service.ts +++ b/frontend/src/app/services/auth.service.ts @@ -1,12 +1,7 @@ -import { - HttpClient, - HttpErrorResponse, - HttpHeaders, -} from '@angular/common/http'; +import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { lastValueFrom, Observable } from 'rxjs'; +import { lastValueFrom } from 'rxjs'; import { environment } from '../environments/environment.development'; -import { Router } from '@angular/router'; @Injectable({ providedIn: 'root', @@ -14,25 +9,24 @@ import { Router } from '@angular/router'; export class AuthService { errorMsg: string | null = null; - constructor(private http: HttpClient, private router: Router) {} + constructor(private http: HttpClient) {} - async login(body: any): Promise