Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. @Component({
  2. selector: 'ddi-login-page',
  3. templateUrl: 'login-page.component.html'
  4. })
  5. export class LoginPageComponent implements OnInit {
  6.  
  7. user: User;
  8.  
  9. constructor(private userService: UserService,
  10. private routingService: RoutingService) {
  11. }
  12.  
  13. ngOnInit() {
  14. this.user = User.instance();
  15.  
  16. // mock data
  17. this.user.username = 'admin';
  18. this.user.password = 'admin123';
  19. }
  20.  
  21. login() {
  22. this.userService.login(this.user.username, this.user.password)
  23. .then(res => {
  24. const urlToGoAfterLogin = this.routingService.lastPageUrl;
  25. if (urlToGoAfterLogin) {
  26. this.routingService.goTo(urlToGoAfterLogin);
  27. } else {
  28. this.routingService.goToMenuPage();
  29. }
  30. this.routingService.lastPageUrl = '';
  31. });
  32. }
  33.  
  34. logout() {
  35. this.userService.logout();
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement