/
sam_single_1
/
Fronend
Обзор
Документация
Войти
/
sam_single_1
/
Fronend
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/AuthModule/vk/http/auth_requests.js
61 строка
2 KB
sam_single_1
First Commit
23 окт 2024, 12:13
23 окт 2024, 12:13
7302d97
Код
Авторство
О чём код?
import { auth_instance, private_authed_instance } from "./axios"; import { ts, UDTO } from "../../TypesValidation/udto"; export async function api_request_first_login() { const res_type = { state: ts.s, code_challenge: ts.s }; const res_err = [""]; const res = await auth_instance .get("/login/first") .then((response) => { return { state: response.data.state, code_challenge: response.data.code_challenge, }; }) .catch((error) => { return "no"; }); return new UDTO(res_type, res, res_err); } export async function api_request_second_login(r) { const res_type = { access_token: ts.s, user_id: ts.n }; const res_err = [""]; if (r.err) { return r; } else { const res = await auth_instance .post("/login/second", r.pl) .then((response) => { return { access_token: response.data.access_token, user_id: response.data.user_id, device_id: response.data.device_id, }; }) .catch((error) => { return {}; }); return new UDTO(res_type, res, res_err); } } export async function api_request_logout() { await private_authed_instance.get("/logout"); } export async function api_request_refresh() { const res_type = { access_token: ts.s }; const res_err = [""]; const res = await auth_instance .get("/refresh") .then((response) => { return response.data.access_token; }) .catch((error) => { return {}; }); return new UDTO(res_type, res, res_err); }