mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-21 05:45:46 +00:00
39 lines
879 B
TypeScript
39 lines
879 B
TypeScript
import axios from 'axios';
|
|
import { httpClient } from '@/services/http/client';
|
|
import { BaseApiResponse, LogoutResponse } from '@/types/api/api-general';
|
|
|
|
export class AuthApiService {
|
|
async logout() {
|
|
try {
|
|
const logoutRes = await httpClient<LogoutResponse>(`/sso/logout`, {
|
|
method: 'POST',
|
|
});
|
|
|
|
return logoutRes;
|
|
} catch (error) {
|
|
if (axios.isAxiosError<BaseApiResponse>(error)) {
|
|
return error.response?.data;
|
|
}
|
|
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
async refresh() {
|
|
try {
|
|
const refreshRes = await httpClient<BaseApiResponse>(`/sso/refresh`, {
|
|
method: 'POST',
|
|
});
|
|
|
|
return refreshRes;
|
|
} catch (error) {
|
|
if (axios.isAxiosError<BaseApiResponse>(error)) {
|
|
return error.response?.data;
|
|
}
|
|
return undefined;
|
|
}
|
|
}
|
|
}
|
|
|
|
export const AuthApi = new AuthApiService();
|