Structor CSSD

This commit is contained in:
saeid
2019-04-25 20:14:09 +04:30
parent fc162db99b
commit 14a91bdef7
72 changed files with 6957 additions and 4636 deletions
+7 -18
View File
@@ -1,5 +1,6 @@
import { ApiService } from "../global/api.service";
import { TokenService } from "./storage.service";
import { urls } from "@/config/urls";
class AuthenticationError extends Error {
constructor(errorCode, message) {
@@ -20,7 +21,7 @@ const UserService = {
login: async function(cell_number, password) {
const requestData = {
method: "post",
url: "/login",
url: urls.login,
data: {
cell_number,
password,
@@ -120,7 +121,7 @@ const UserService = {
const requestData = {
method: "post",
url: "login",
url: urls.login,
data: {
grant_type: "refresh_token",
refresh_token: refreshToken
@@ -154,13 +155,8 @@ const UserService = {
* Will also remove `Authorization Bearer <token>` header from future requests.
**/
logout: async function() {
const requestData = {
method: "post",
url: "logout"
};
try {
const response = await ApiService.customRequest(requestData);
const response = await ApiService.post(urls.logout);
// Remove the token and remove Authorization header from Api Service as well
TokenService.removeToken();
TokenService.removeRefreshToken();
@@ -184,16 +180,9 @@ const UserService = {
* Will also Register in Store;
**/
getInfo: async function() {
const requestData = {
method: "get",
url: "getInfo"
};
const response = await ApiService.customRequest(requestData);
TokenService.saveInfo(response.data);
return response.data;
const response = await ApiService.get(urls.getInfo);
TokenService.saveInfo(response.data.data);
return response.data.data;
}
};