Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ready() {
- super.ready();
- this.$.login.addEventListener('login', this.login);
- this.$.login.addEventListener('forgot-password', this.forgotPassword);
- }
- login(e) {
- const username = e.detail.username;
- const password = e.detail.password;
- auth.signInWithEmailAndPassword(username, password)
- .then(user => {
- // why doesn't this work
- this.getUserFromFirestore(user.uid);
- })
- .catch(error => {
- console.log(error);
- // why doesn't this work
- this.$.login.error = true;
- });
- }
- getUserFromFirestore(uid) {
- firestore.collection('users').doc(uid)
- .get()
- .then(doc => {
- let user = doc.data();
- console.log(user.role);
- })
- .catch(error => {
- console.log(error);
- });
- }
- constructor () {
- this.login = this.login.bind(this);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement