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 {
|
export class HomePage implements OnInit {
|
||||||
|
|
||||||
neighbours: Observable<any[]>;
|
neighbours: Observable<any[]>;
|
||||||
|
buttonTitle = "Login";
|
||||||
|
_authInfo: any;
|
||||||
|
displayName: any;
|
||||||
|
|
||||||
constructor(public navCtrl: NavController, private _af: AngularFire,
|
constructor(public navCtrl: NavController, private _af: AngularFire,
|
||||||
private _neighboursService: NeighboursService) {
|
private _neighboursService: NeighboursService) {
|
||||||
@@ -23,7 +26,17 @@ export class HomePage implements OnInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this._af.auth.subscribe((data) => {
|
this._af.auth.subscribe((data) => {
|
||||||
if (data) {
|
if (data) {
|
||||||
|
this.buttonTitle = "Logout";
|
||||||
this._af.auth.unsubscribe();
|
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 {
|
} else {
|
||||||
this._displayLoginModal();
|
this._displayLoginModal();
|
||||||
}
|
}
|
||||||
@@ -31,6 +44,16 @@ export class HomePage implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logoutClicked() {
|
||||||
|
if (this._authInfo && (this._authInfo.email || this._authInfo.providerId)) {
|
||||||
|
this._af.auth.logout();
|
||||||
|
this._authInfo = null
|
||||||
|
this._displayLoginModal()
|
||||||
|
} else {
|
||||||
|
this._displayLoginModal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
registerMe() {
|
registerMe() {
|
||||||
this._neighboursService.registerMe();
|
this._neighboursService.registerMe();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user