Guest User

Untitled

a guest
Jan 6th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. import { Component, OnInit, Output, EventEmitter } from '@angular/core';
  2. import * as Parse from 'parse';
  3.  
  4. @Component({
  5. selector: 'app-login',
  6. templateUrl: './login.component.html',
  7. styleUrls: ['./login.component.styl']
  8. })
  9. export class LoginComponent implements OnInit {
  10. currentUser:void|Parse.User;
  11. userName = '';
  12. userPassword = '';
  13. @Output() login: EventEmitter<boolean> = new EventEmitter();
  14.  
  15. async onSubmit(e) {
  16. e.preventDefault();
  17. this.currentUser = await Parse.User.logIn(this.userName, this.userPassword).catch(e => console.log('login failed', e));
  18. if(this.currentUser) this.login.emit(true);
  19. }
  20.  
  21. logOutUser() {
  22. Parse.User.logOut().then(() => {
  23. this.currentUser = Parse.User.current();
  24. if(this.currentUser) this.login.emit(false);
  25. });
  26. }
  27.  
  28. constructor() { }
  29.  
  30. ngOnInit() {
  31. this.currentUser = Parse.User.current();
  32. }
  33.  
  34. }
Add Comment
Please, Sign In to add comment