I am using simple user authentication using angularfire2 and the Firebase authentication service.
import { Injectable } from '@angular/core';
import { AngularFire } from 'angularfire2';
import { Cookie } from 'ng2-cookies';
@Injectable()
export class GlobalMenuService {
loggedIn: boolean = false;
constructor(private af: AngularFire) { }
login(email: string, password: string) {
this.af.auth.login({
email: email,
password: password
})
.then((success) => {
this.loggedIn = true;
});
}
logout() {
this.af.auth.logout();
this.loggedIn = false;
}
}
Is there a way to store some data in a cookie (token, uid, email, or something else) to restore the session, i.e. every time the user returns to the application, log in again without having to enter credentials?
source
share