我的Ionic 2 app as Google Authentication通过Firebase,我在应用程序中有一个注销按钮,调用Firebase unauth()
方法,但只能验证Firebase引用并且不会终止Google OAuth会话。如何在Ionic 2应用程序中杀死Google OAuth会话(通过Firebase)?
在按下注销按钮并再次按下登录按钮后,用户会自动登录(使用先前的OAuth会话),我不想那样做。
我需要我的注销按钮来杀死Google OAuth会话,因此当再次按下登录按钮时,它会再次提示输入用户名和密码。我怎样才能做到这一点?
这里是我的代码:
home.ts
import {Page} from 'ionic-angular';
@Page({
templateUrl: 'build/pages/home/home.html'
})
export class HomePage {
firebaseUrl: string;
ref: Firebase;
constructor() {
this.firebaseUrl = 'https://xxx.firebaseio.com';
this.ref = new Firebase(this.firebaseUrl);
}
login() {
this.ref.authWithOAuthPopup("google", (error, authData) => {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully with payload:", authData);
}
});
}
logout() {
this.ref.unauth();
console.log('Logout button clicked');
}
}
home.html的
<ion-navbar *navbar>
<ion-title>
Home
</ion-title>
</ion-navbar>
<ion-content class="home">
<button (click)="login()">Sign in with Google</button>
<button (click)="logout()">Logout</button>
</ion-content>
我有同样的问题。如果您发现任何解决方案,请更新此帖子! – henrikmerlander