@nunoarruda wrote:
My Ionic 2 app as Google Authentication via Firebase and I have a logout button in the app calling the Firebase
unauth()
method but that only unauthenticates the Firebase reference and does not kill the Google OAuth session.After pressing the logout button and pressing the login button again the user is automatically logged in (using the previous OAuth session) and I don't want that.
I need my logout button to also kill the Google OAuth session so when the login button is pressed again it prompts for the username and password once more. How can I achieve that?
Here's my code:
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>
Posts: 3
Participants: 2