mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-13 08:21:06 +03:30
Structor CSSD
This commit is contained in:
+7
-18
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user