私の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