我的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