Advertisement
Guest User

Untitled

a guest
Mar 27th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import { User } from './user';
  2. import { Injectable } from '@angular/core';
  3. import { Router } from '@angular/router';
  4.  
  5. @Injectable({
  6. providedIn: 'root'
  7. })
  8. export class UserAuthService {
  9. currentUser:User;
  10. redirectURL:string;
  11.  
  12. constructor(private _route:Router) { }
  13. get isLoggedIn():boolean{
  14. return !!this.currentUser;
  15. }
  16. logIn(username:string,password:string):void {
  17. if(username==='admin'){
  18. this.currentUser={
  19. id:'admin@gmail.com',
  20. uname:'admin',
  21. isAdmin:true
  22. }
  23. return;
  24. }
  25. this.currentUser={
  26. id:username+'@gmail.com',
  27. uname:username,
  28. isAdmin:false
  29. }
  30. }
  31. logout(){
  32. this.currentUser=null;
  33. this._route.navigate(['/home']);
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement