Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
login routes to generator search if proper login inputted
  • Loading branch information
rrc12004 committed Feb 28, 2019
1 parent 8686b08 commit 52c735d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/app/app.module.ts
Expand Up @@ -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},
Expand All @@ -41,7 +41,7 @@ import { SignUpComponent } from './sign-up/sign-up.component';
{path: 'sign_up', component: SignUpComponent},

]),

],
providers: [],
bootstrap: [AppComponent]
Expand Down
16 changes: 11 additions & 5 deletions src/app/authentication/authentication.component.ts
Expand Up @@ -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({
Expand All @@ -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 () {
Expand All @@ -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');
}

});
}

Expand Down

0 comments on commit 52c735d

Please sign in to comment.