Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. ready() {
  2. super.ready();
  3.  
  4. this.$.login.addEventListener('login', this.login);
  5. this.$.login.addEventListener('forgot-password', this.forgotPassword);
  6. }
  7.  
  8. login(e) {
  9. const username = e.detail.username;
  10. const password = e.detail.password;
  11.  
  12. auth.signInWithEmailAndPassword(username, password)
  13. .then(user => {
  14. // why doesn't this work
  15. this.getUserFromFirestore(user.uid);
  16. })
  17. .catch(error => {
  18. console.log(error);
  19. // why doesn't this work
  20. this.$.login.error = true;
  21. });
  22. }
  23.  
  24. getUserFromFirestore(uid) {
  25. firestore.collection('users').doc(uid)
  26. .get()
  27. .then(doc => {
  28. let user = doc.data();
  29. console.log(user.role);
  30. })
  31. .catch(error => {
  32. console.log(error);
  33. });
  34. }
  35.  
  36. constructor () {
  37. this.login = this.login.bind(this);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement