Added logout
Change-Id: If09690e089976244ded58a27b1f35a3a850ae2d1
diff --git a/src/app/datasources/rest/auth.rest.spec.ts b/src/app/datasources/rest/auth.rest.spec.ts
index 85aefb4..16c0f8d 100644
--- a/src/app/datasources/rest/auth.rest.spec.ts
+++ b/src/app/datasources/rest/auth.rest.spec.ts
@@ -69,9 +69,9 @@
it('should remove user auth from cookies', (done) => {
service.logout()
.then((res) => {
- expect($cookies.get('xoscsrftoken')).toEqual(null);
- expect($cookies.get('xossessionid')).toEqual(null);
- expect($cookies.get('xosuser')).toEqual(null);
+ expect($cookies.get('xoscsrftoken')).toEqual(undefined);
+ expect($cookies.get('xossessionid')).toEqual(undefined);
+ expect($cookies.get('xosuser')).toEqual(undefined);
done();
})
.catch(e => {
diff --git a/src/app/datasources/rest/auth.rest.ts b/src/app/datasources/rest/auth.rest.ts
index 1792920..e7a593c 100644
--- a/src/app/datasources/rest/auth.rest.ts
+++ b/src/app/datasources/rest/auth.rest.ts
@@ -13,9 +13,15 @@
};
}
+export interface IXosUser {
+ id: number;
+ email: string;
+}
+
export interface IXosAuthService {
login(data: IAuthRequestData): Promise<any>;
logout(): Promise<any>;
+ getUser(): IXosUser;
}
export class AuthService {
@@ -44,7 +50,7 @@
public logout(): Promise<any> {
const d = this.$q.defer();
- this.$http.post(`${AppConfig.apiEndpoint}/utility/login/`, {
+ this.$http.post(`${AppConfig.apiEndpoint}/utility/logout/`, {
xoscsrftoken: this.$cookies.get('xoscsrftoken'),
xossessionid: this.$cookies.get('xossessionid')
})
@@ -59,4 +65,8 @@
});
return d.promise;
}
+
+ public getUser(): IXosUser {
+ return JSON.parse(this.$cookies.get('xosuser'));
+ }
}