Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pages/profile/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<div class="buttons-div">
<button ion-button class="buttons1" outline color="dark">Edit Profile</button>

<button ion-button outline class="buttons1" color="dark">Logout</button>
<button ion-button outline class="buttons1" color="dark" (click)='onLogout()'>Logout</button>
</div>

</ion-content>
11 changes: 10 additions & 1 deletion src/pages/profile/profile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { UserProvider } from '../../providers/user/user';

/**
* Generated class for the ProfilePage page.
Expand All @@ -14,11 +15,19 @@ import { NavController, NavParams } from 'ionic-angular';
})
export class ProfilePage {

constructor(public navCtrl: NavController, public navParams: NavParams) {
constructor(public navCtrl: NavController, public navParams: NavParams, public user :UserProvider) {
}

ionViewDidLoad() {
console.log('ionViewDidLoad ProfilePage');
}

onLogout() {
this.user.logoutUser(window.sessionStorage.getItem('token'))
.subscribe( response => {
console.log('onsubscibe-logout')
window.sessionStorage.clear()
})
}

}
6 changes: 6 additions & 0 deletions src/providers/user/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ export class UserProvider {
return this.http.post(this.requestUrl + '/appUsers/login', creds);
}

logoutUser(token:any) {
console.log('onservice-logout')
return this.http.post(this.requestUrl + "/appUsers/logout", token )
}

getUser(id) {
return this.http.get(this.requestUrl + '/appUsers/' + id)

}
}