I'm building a website using Angular and Firebase. I'm using Angularfire2 and AngularFireAuth libraries and GoogleAuthProvider (Google) as my authentication provider.
Here is my service code:
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';
@Injectable()
export class AuthenticationService {
user: Observable<firebase.User>;
constructor(public afAuth: AngularFireAuth) {
this.user = afAuth.authState;
}
login() {
this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
}
logout() {
this.afAuth.auth.signOut();
}
}
When a user 'logs out' of my site, it works, but seems to 'cache' the Google authentication. So when they attempt to login a second time I run into a few problems:
- User is not allowed to choose another Google account to login with.
- User is automatically logged in...which seems like a security problem. Another user could come to the same shared PC, and login as the previous user and is not required to type in a password to do so.
What am I doing wrong? Is there a way I can stop angularfire2/auth from caching these credentials? Is there a way to log users out of Google when they log out of my site?