Added tests
Change-Id: I493675212f4b1548b32a6d92ce3664d184bc0e04
diff --git a/src/app/datasources/rest/auth.rest.ts b/src/app/datasources/rest/auth.rest.ts
index a94599a..f71d295 100644
--- a/src/app/datasources/rest/auth.rest.ts
+++ b/src/app/datasources/rest/auth.rest.ts
@@ -12,6 +12,11 @@
xossessionid: string;
};
}
+
+export interface IXosAuthService {
+ login(data: IAuthRequestData): Promise<any>;
+ logout(): Promise<any>;
+}
export class AuthService {
@@ -38,4 +43,22 @@
});
return d.promise;
}
+
+ public logout(): Promise<any> {
+ const d = this.$q.defer();
+ this.$http.post(`${AppConfig.apiEndpoint}/utility/login/`, {
+ xoscsrftoken: this.$cookies.get('xoscsrftoken'),
+ xossessionid: this.$cookies.get('xossessionid')
+ })
+ .then(() => {
+ this.$cookies.remove('xoscsrftoken');
+ this.$cookies.remove('xossessionid');
+ this.$cookies.remove('xosuser');
+ d.resolve();
+ })
+ .catch(e => {
+ d.reject(e);
+ });
+ return d.promise;
+ }
}