mirror of
https://github.com/fergalmoran/icebreaker-mobile.git
synced 2025-12-22 09:39:31 +00:00
Fixed login flow
This commit is contained in:
@@ -15,6 +15,9 @@ import {NeighboursService} from '../../services/neighbours.service';
|
||||
export class HomePage implements OnInit {
|
||||
|
||||
neighbours: Observable<any[]>;
|
||||
buttonTitle = "Login";
|
||||
_authInfo: any;
|
||||
displayName: any;
|
||||
|
||||
constructor(public navCtrl: NavController, private _af: AngularFire,
|
||||
private _neighboursService: NeighboursService) {
|
||||
@@ -23,13 +26,33 @@ export class HomePage implements OnInit {
|
||||
ngOnInit() {
|
||||
this._af.auth.subscribe((data) => {
|
||||
if (data) {
|
||||
this.buttonTitle = "Logout";
|
||||
this._af.auth.unsubscribe();
|
||||
if (data.auth.providerData[0].providerId === "twitter.com") {
|
||||
this._authInfo = data.auth.providerData[0]
|
||||
this.displayName = data.auth.providerData[0].displayName
|
||||
} else if (data.github) {
|
||||
this._authInfo = data.github
|
||||
} else {
|
||||
this._authInfo = data.auth || {}
|
||||
this.displayName = data.auth.providerData[0].email
|
||||
}
|
||||
} else {
|
||||
this._displayLoginModal();
|
||||
}
|
||||
this.neighbours = this._neighboursService.getNeighbours();
|
||||
});
|
||||
}
|
||||
|
||||
logoutClicked() {
|
||||
if (this._authInfo && (this._authInfo.email || this._authInfo.providerId)) {
|
||||
this._af.auth.logout();
|
||||
this._authInfo = null
|
||||
this._displayLoginModal()
|
||||
} else {
|
||||
this._displayLoginModal()
|
||||
}
|
||||
}
|
||||
|
||||
registerMe() {
|
||||
this._neighboursService.registerMe();
|
||||
|
||||
Reference in New Issue
Block a user