Guest User

Untitled

a guest
Feb 3rd, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. onLoginSubmit(){
  2. //console.log(this.username);
  3. const user = {
  4. username: this.username,
  5. password: this.password
  6. }
  7.  
  8. this.authService.authenticateUser(user).subscribe(data => {
  9. //console.log(data);
  10. if(data.success){
  11. this.authService.storeUserData(data.token, data.user);
  12.  
  13. this.flashMessage.show('You are now logged in', {
  14. cssClass: 'alert-success',
  15. timeout: 5000});
  16. this.router.navigate(['dashboard']);
  17.  
  18. }else{
  19. this.flashMessage.show(data.msg, {
  20. cssClass: 'alert-danger',
  21. timeout: 5000});
  22. this.router.navigate(['login']);
  23. }
  24.  
  25. });
  26. }
Add Comment
Please, Sign In to add comment