Javascript 使用angular 2登录gmail注销后未正确登录
当我第一次使用gmail帐户登录时,它会正常工作,但当我通过我的应用程序注销我的帐户时,它会清除本地存储,注销过程和G-mail-signIn按钮再次呈现,但当我单击它时,它就不工作了,我不明白发生了什么 登录过程Javascript 使用angular 2登录gmail注销后未正确登录,javascript,Javascript,当我第一次使用gmail帐户登录时,它会正常工作,但当我通过我的应用程序注销我的帐户时,它会清除本地存储,注销过程和G-mail-signIn按钮再次呈现,但当我单击它时,它就不工作了,我不明白发生了什么 登录过程 控制台中是否有错误?使用firebase auth如何?像在本教程中一样,获取一个错误:TypeError:无法读取G_处null的属性“style”(cb=gapi.loaded_1:90) login html page <div class="col-md-12 col
控制台中是否有错误?使用firebase auth如何?像在本教程中一样,获取一个错误:TypeError:无法读取G_处null的属性“style”(cb=gapi.loaded_1:90)
login html page
<div class="col-md-12 col-sm-12 col-xs-12 col-lg-12" *ngIf="isLogin">
<div id="{{googleLoginButtonId}}"></div>
</div>
ngOnInit() {
console.log("initCalled");
// Converts the Google login button stub to an actual button.
gapi.load('auth2', function () {
auth2 = gapi.auth2.getAuthInstance({
client_id: '656224112655-n9t6aesubdfpdtb1vjk0rnh9r6np2ug7.apps.googleusercontent.com',
hosted_domain: ConstantValues.hosted_domain,
scope: 'profile'
});
// auth2 = gapi.auth2.getAuthInstance();
//var dataSigned = auth2.isSignedIn;
//console.log("auth2-------", dataSigned.Ab);
//console.log("dataSigned-----", auth2)
});
}
// Angular hook that allows for interaction with elements inserted by the
// rendering of a view.
ngAfterViewInit() {
gapi.signin2.render(
this.googleLoginButtonId,
{
"onSuccess": this.onGoogleLoginSuccess,
"onFailure": this.onSignInFailure,
"scope": "profile",
"theme": "dark"
});
setTimeout(function () {
this.googleLoginButtonId = this.googleLoginButtonId
},
1000);
}
// Triggered after a user successfully logs in using the Google external
// login provider.
onGoogleLoginSuccess = (loggedInUser) => {
this._zone.run(() => {
this.userAuthToken = loggedInUser.getAuthResponse().id_token;
this.user.userName = loggedInUser.getBasicProfile().getName();
this.user.userMail = loggedInUser.getBasicProfile().getEmail();
localStorage.setItem('userMail', this.user.userMail);
localStorage.setItem('userName', this.user.userName);
console.log("Successfull--------Login", this);
localStorage.setItem('isLogin', "true");
this.broadcastValue.alertUserLoginOrLogout(true);
console.log("at the tym of login success");
console.log(this);
});
}
onSignInFailure = (loggedInUser) => {
console.log("Login Failed!!");
this.broadcastValue.alertUserLoginOrLogout(false);
this.toaster.showError('Please login with daffodilsw.com!', 'Login Failure!');
}
}
//logout process
signOutFunc = () => {
console.log("-Router-", this);
localStorage.removeItem('role');
localStorage.removeItem('userName');
localStorage.removeItem('userMail');
localStorage.setItem('isLogin', "false");
this.broadcastValue.alertUserLoginOrLogout(false);
this.broadcastValue.alertRoleExistance(false);
}