我正在使用带有 angularfire2 的简单自定义身份验证和 Firebase 的身份验证服务。
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;
}
}
有没有办法将一些数据保存在 cookie(令牌、uid、电子邮件或其他东西)中以恢复会话,即每次用户返回应用程序时重新登录他而无需编写凭据?