Skip to content

Commit 8eb42d4

Browse files
author
mkobar
committed
added logout
1 parent b9895bc commit 8eb42d4

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

src/pages/home/home.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
My Bills
55
</ion-title>
66
<ion-buttons end>
7+
<button ion-button color="danger" (click)="logoutNow()">Logout
8+
</button>
79
<button ion-button icon-only (click)="createBill()">
810
<ion-icon name="add"></ion-icon>
911
</button>
@@ -40,4 +42,4 @@ <h3>Total:
4042
</h3>
4143
</ion-item>
4244
</ion-list>
43-
</ion-content>
45+
</ion-content>

src/pages/home/home.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ import {
33
NavController,
44
ActionSheet,
55
ActionSheetController,
6+
Loading,
7+
LoadingController,
68
Platform
79
} from 'ionic-angular';
810
import { Observable } from 'rxjs/Observable';
911
import { BillProvider } from '../../providers/bill/bill';
12+
import { AuthProvider } from '../../providers/auth/auth';
1013

1114
@Component({
1215
selector: 'page-home',
@@ -17,8 +20,10 @@ export class HomePage {
1720
constructor(
1821
public navCtrl: NavController,
1922
public actionCtrl: ActionSheetController,
23+
public loadingCtrl: LoadingController,
2024
public platform: Platform,
21-
public billProvider: BillProvider
25+
public billProvider: BillProvider,
26+
public authProvider: AuthProvider
2227
) { }
2328

2429
ionViewDidLoad() {
@@ -72,4 +77,21 @@ export class HomePage {
7277
action.present();
7378
}
7479

80+
logoutNow(): void {
81+
this.authProvider.logoutUser().then(newUser => {
82+
loading.dismiss().then(() => {
83+
this.navCtrl.setRoot(LandingPage);
84+
});
85+
}).catch(error => {
86+
loading.dismiss().then(() => {
87+
console.error("logoutNow ",error);
88+
});
89+
});
90+
91+
const loading: Loading = this.loadingCtrl.create();
92+
loading.present();
93+
94+
//this.navCtrl.push('LandingPage');
95+
}
96+
7597
}

src/pages/login/login.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class LoginPage {
5555
error => {
5656
this.loading.dismiss().then(() => {
5757
const alert: Alert = this.alertCtrl.create({
58-
message: error.message,
58+
message: 'loginUser '+error.message,
5959
buttons: [
6060
{
6161
text: 'OK',

0 commit comments

Comments
 (0)