diff --git a/frontend/src/app/pages/auth-signin/auth-signin.component.html b/frontend/src/app/pages/auth-signin/auth-signin.component.html index 1a4d7d89..8e8f7481 100644 --- a/frontend/src/app/pages/auth-signin/auth-signin.component.html +++ b/frontend/src/app/pages/auth-signin/auth-signin.component.html @@ -5,21 +5,42 @@

Welcome back!

Please sign in to continue

-
+
- + + +
+
+ Email is required. +
+
+ Email must be at least 4 characters long. +
+
+ Email is not a valid email address. +
+
- + + +
+
+ Password is required. +
+
+ Password must be at least 8 characters long. +
+
- Sign In +
diff --git a/frontend/src/app/pages/auth-signin/auth-signin.component.ts b/frontend/src/app/pages/auth-signin/auth-signin.component.ts index 161d188b..f51a4b30 100644 --- a/frontend/src/app/pages/auth-signin/auth-signin.component.ts +++ b/frontend/src/app/pages/auth-signin/auth-signin.component.ts @@ -1,4 +1,7 @@ import { Component, OnInit } from '@angular/core'; +import {User} from '../../models/fasten/user'; +import {FastenApiService} from '../../services/fasten-api.service'; +import {Router} from '@angular/router'; @Component({ selector: 'app-auth-signin', @@ -6,10 +9,21 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./auth-signin.component.scss'] }) export class AuthSigninComponent implements OnInit { + submitted: boolean = false + existingUser: User = new User() - constructor() { } + constructor(private fastenApi: FastenApiService, private router: Router) { } ngOnInit(): void { } + signinSubmit(){ + this.submitted = true; + + this.fastenApi.signin(this.existingUser.username, this.existingUser.password).subscribe((tokenResp: any) => { + console.log(tokenResp); + + this.router.navigateByUrl('/dashboard'); + }) + } } diff --git a/frontend/src/app/pages/auth-signup/auth-signup.component.html b/frontend/src/app/pages/auth-signup/auth-signup.component.html index a123ab75..0a2a16a8 100644 --- a/frontend/src/app/pages/auth-signup/auth-signup.component.html +++ b/frontend/src/app/pages/auth-signup/auth-signup.component.html @@ -7,8 +7,6 @@

We are excited to launch our new company and product Azia. After being featured in too many magazines to mention and having created an online stir, we know that BootstrapDash is going to be big. We also hope to win Startup Fictional Business of the Year this year.

Browse our site and see for yourself why you need Azia.

Learn More - - {{ newUser | json }}
@@ -58,7 +56,7 @@ Password is required.
- Name must be at least 8 characters long. + Password must be at least 8 characters long.
@@ -66,7 +64,7 @@ diff --git a/frontend/src/app/pages/auth-signup/auth-signup.component.ts b/frontend/src/app/pages/auth-signup/auth-signup.component.ts index 2cc27210..d9a6d896 100644 --- a/frontend/src/app/pages/auth-signup/auth-signup.component.ts +++ b/frontend/src/app/pages/auth-signup/auth-signup.component.ts @@ -26,7 +26,6 @@ export class AuthSignupComponent implements OnInit { this.router.navigateByUrl('/dashboard'); }) - } } diff --git a/frontend/src/app/services/fasten-api.service.ts b/frontend/src/app/services/fasten-api.service.ts index c04675eb..5453c3b1 100644 --- a/frontend/src/app/services/fasten-api.service.ts +++ b/frontend/src/app/services/fasten-api.service.ts @@ -46,23 +46,19 @@ export class FastenApiService { } - signin(email: string, pass: string) { - const headers = { - headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Cache-Control': 'no-cache' }) - }; + signin(username: string, pass: string): Observable { const data = { - email: email, + username: username, password: pass }; - this._httpClient.post(`${this.getBasePath()}/api/auth/signin`, data, headers).subscribe( - (res: any) => { - localStorage.setItem(this.AUTH_TOKEN_KEY, res.token); - - this.router.navigateByUrl('/dashboard'); + return this._httpClient.post(`${this.getBasePath()}/api/auth/signin`, data).pipe( + map((res: any) => { + localStorage.setItem(this.AUTH_TOKEN_KEY, res.data); + return res.data } - ); + )); }