使用角度2的Firebase身份验证

时间:2017-09-27 17:19:19

标签: angular firebase firebase-authentication

谷歌的身份验证工作正常,如用户名和密码,但当谷歌登录时,标题功能运行缓慢,用户名和密码登录工作正常?这是什么原因?

signInByEmail(email,password) {
        return this.afAuth.auth.signInWithEmailAndPassword(email, password)
            .then(
                (success)=> {                 
                    this.afAuth.auth.currentUser.getIdToken()
                    .then(token => {
                        let params = new URLSearchParams();
                        params.set('tsid', `Bearer ${token}`);
                        this.auth.setToken(token);
                    });                 
                    localStorage.setItem('emailUser', email);
                    this.router.navigateByUrl('/');
                }
            ).catch(
                (err)=> {
                    this.showAlert();
                    console.log(err);
                }
            );
     }

     signInByGoogle(){
        return this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider()).then(
                (success)=> {
                    this.afAuth.auth.currentUser.getIdToken()
                    .then(token => {
                        let params = new URLSearchParams();
                        params.set('tsid', `Bearer ${token}`);
                        this.auth.setToken(token);
                    });
                    localStorage.setItem('emailUser', JSON.stringify(success.user.email));
                    this.router.navigateByUrl('/');
                }
            ).catch(
                (err)=> {
                    console.log(err);
                }
            );
     }

app-root中有HostBending

export class AppComponent implements OnInit {
    @HostBinding('class.layout-fixed') get isFixed() { return this.settings.layout.isFixed; };
}

1 个答案:

答案 0 :(得分:0)

我找到了这个问题的答案 社交链接登录按钮必须在标签内