diff --git a/src/app/app.module.ts b/src/app/app.module.ts index d59b0af..280c8bc 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -31,7 +31,7 @@ import { SignUpComponent } from './sign-up/sign-up.component'; BrowserAnimationsModule, HttpClientModule, RouterModule.forRoot([ - + {path: 'dashboard', component: FrontpageComponent}, {path: '', component: AuthenticationComponent}, {path: 'generator-search', component: GeneratorSearchComponent}, @@ -41,7 +41,7 @@ import { SignUpComponent } from './sign-up/sign-up.component'; {path: 'sign_up', component: SignUpComponent}, ]), - + ], providers: [], bootstrap: [AppComponent] diff --git a/src/app/authentication/authentication.component.ts b/src/app/authentication/authentication.component.ts index 4f4486d..255bea9 100644 --- a/src/app/authentication/authentication.component.ts +++ b/src/app/authentication/authentication.component.ts @@ -2,7 +2,7 @@ import {Component, ElementRef, OnInit, ViewChild} from '@angular/core'; import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { LoginService } from '../services/login.service'; - +import { Router } from '@angular/router'; @Injectable() @Component({ @@ -15,7 +15,7 @@ export class AuthenticationComponent implements OnInit { @ViewChild('email_input') email_input: ElementRef; @ViewChild('password_input') password_input: ElementRef; - constructor(private data: LoginService) { + constructor(private data: LoginService, private router: Router) { } logOn () { @@ -27,9 +27,15 @@ export class AuthenticationComponent implements OnInit { this.data.authorizeUser(loginjson).subscribe((data) => { const token = data['token']; - // Authorized - console.log(token); - localStorage.setItem('auth_token', token); + const message = data['message']; + if (message === 'Authorized') { + // Authorized + // console.log(token); + localStorage.setItem('auth_token', token); + // window.open(); + this.router.navigateByUrl('/generator-search'); + } + }); }