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,
|
data: AuthAPI.POST.Login.Params,
|
||||||
): Promise<AuthAPI.POST.Login.Response> => baseApi.post('login', data)
|
): 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}`)
|
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 namespace YandexCallBack {
|
||||||
export type Params = { token: string }
|
export type Params = { token: string }
|
||||||
export type Response = AxiosResponse<{
|
export type Response = AxiosResponse<{
|
||||||
|
data : {
|
||||||
access_token: string,
|
access_token: string,
|
||||||
success: boolean,
|
success: boolean,
|
||||||
token_type: string,
|
token_type: string,
|
||||||
message: string | null
|
message: string | null
|
||||||
|
}
|
||||||
}>
|
}>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,13 +46,15 @@ export const useAuthStore = defineStore(Stores.AUTH, () => {
|
|||||||
|
|
||||||
const onYandex = async () => {
|
const onYandex = async () => {
|
||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true;
|
||||||
const res = await loginYandex()
|
const res = await loginYandex();
|
||||||
await router.push({ name: Routes.INDEX })
|
const redirect_url = res.data
|
||||||
|
console.log(res.data);
|
||||||
|
window.location.href = res.data;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.log(e.response.data.message)
|
console.log(e.response.data.message)
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,6 @@ export const callBack = async () => {
|
|||||||
|
|
||||||
const data = await YandexCallBack(token);
|
const data = await YandexCallBack(token);
|
||||||
setJWT(data.data.data.access_token);
|
setJWT(data.data.data.access_token);
|
||||||
|
console.log(data.data.data.access_token)
|
||||||
router.push({ name : Routes.INDEX });
|
router.push({ name : Routes.INDEX });
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user