From a5f17b80eb728d0149bb92e6819cd28add333c5e Mon Sep 17 00:00:00 2001 From: kevinpauer Date: Sun, 27 Mar 2022 21:33:35 +0200 Subject: [PATCH] Update Login and Registration for new api configuration --- frontend/src/app/Services/auth.service.ts | 9 ++++---- .../src/app/Views/login/login.component.html | 22 +++++++++---------- .../src/app/Views/login/login.component.ts | 8 +++---- .../Views/register/register.component.html | 18 +++++++++++++++ .../app/Views/register/register.component.ts | 7 +++--- 5 files changed, 42 insertions(+), 22 deletions(-) diff --git a/frontend/src/app/Services/auth.service.ts b/frontend/src/app/Services/auth.service.ts index 4fcdef9..85ad53a 100644 --- a/frontend/src/app/Services/auth.service.ts +++ b/frontend/src/app/Services/auth.service.ts @@ -11,18 +11,19 @@ const httpOptions = { }) export class AuthService { constructor(private http: HttpClient) {} - login(username: string, password: string): Observable { + login(email: string, password: string): Observable { return this.http.post(AUTH_API + '/login', { - username, + email, password, }); } - register(username: string, password: string): Observable { + register(email: string, username: string, password: string): Observable { return this.http.post( AUTH_API + '/register', { - username, + email, password, + username, }, httpOptions ); diff --git a/frontend/src/app/Views/login/login.component.html b/frontend/src/app/Views/login/login.component.html index b1ce7dc..42f01b4 100644 --- a/frontend/src/app/Views/login/login.component.html +++ b/frontend/src/app/Views/login/login.component.html @@ -14,21 +14,21 @@ class="backgorund" >
- + -
diff --git a/frontend/src/app/Views/login/login.component.ts b/frontend/src/app/Views/login/login.component.ts index dac1bc2..2837bd2 100644 --- a/frontend/src/app/Views/login/login.component.ts +++ b/frontend/src/app/Views/login/login.component.ts @@ -10,7 +10,7 @@ import { Router } from '@angular/router'; }) export class LoginComponent implements OnInit { form: any = { - username: null, + email: null, password: null, }; isLoggedIn = false; @@ -39,15 +39,15 @@ export class LoginComponent implements OnInit { //onSubmit() saves valuable information in session storage onSubmit(): void { - const { username, password } = this.form; - this.authService.login(username, password).subscribe( + const { email, password } = this.form; + this.authService.login(email, password).subscribe( (data) => { this.tokenStorage.saveToken(data.data.token); this.tokenStorage.saveUser(data.data); this.isLoginFailed = false; this.isLoggedIn = true; - this.accountName = username; + this.accountName = email; this.router.navigate(['']); }, (err) => { diff --git a/frontend/src/app/Views/register/register.component.html b/frontend/src/app/Views/register/register.component.html index 486f037..6b21679 100644 --- a/frontend/src/app/Views/register/register.component.html +++ b/frontend/src/app/Views/register/register.component.html @@ -35,6 +35,24 @@
+
+ + +
+
Email is required
+
+ Email must be a valid email address +
+
+
{ this.isSuccessful = true; this.isSignUpFailed = false;