auth api fix and yandex redirect
This commit is contained in:
parent
9fec063a44
commit
5bda27a6bc
@ -14,7 +14,7 @@ export const login = (
|
||||
data: AuthAPI.POST.Login.Params,
|
||||
): Promise<AuthAPI.POST.Login.Response> => baseApi.post('login', data)
|
||||
|
||||
export const loginYandex = (): Promise<YandexAPI.GET.loginYandex.Response> => baseURL.get('/login/yandex/')
|
||||
export const loginYandex = (): Promise<YandexAPI.GET.loginYandex.Response> => baseURL.get('/login/yandex')
|
||||
|
||||
export const YandexCallBack = (token : String): Promise<YandexAPI.GET.YandexCallBack.Response> => baseURL.get(`/login/yandex/callback?access_token=${token}`)
|
||||
|
||||
@ -57,10 +57,12 @@ export namespace YandexAPI {
|
||||
export namespace YandexCallBack {
|
||||
export type Params = { token: string }
|
||||
export type Response = AxiosResponse<{
|
||||
access_token: string,
|
||||
success: boolean,
|
||||
token_type: string,
|
||||
message: string | null
|
||||
data : {
|
||||
access_token: string,
|
||||
success: boolean,
|
||||
token_type: string,
|
||||
message: string | null
|
||||
}
|
||||
}>
|
||||
}
|
||||
}
|
||||
|
@ -46,13 +46,15 @@ export const useAuthStore = defineStore(Stores.AUTH, () => {
|
||||
|
||||
const onYandex = async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
const res = await loginYandex()
|
||||
await router.push({ name: Routes.INDEX })
|
||||
loading.value = true;
|
||||
const res = await loginYandex();
|
||||
const redirect_url = res.data
|
||||
console.log(res.data);
|
||||
window.location.href = res.data;
|
||||
} catch (e: any) {
|
||||
console.log(e.response.data.message)
|
||||
} finally {
|
||||
loading.value = false
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,6 @@ export const callBack = async () => {
|
||||
|
||||
const data = await YandexCallBack(token);
|
||||
setJWT(data.data.data.access_token);
|
||||
|
||||
console.log(data.data.data.access_token)
|
||||
router.push({ name : Routes.INDEX });
|
||||
};
|
Loading…
Reference in New Issue
Block a user