Login:Src:Utils: add TFA constants and getTfaSecretKeyAndQR action

This commit is contained in:
Darya Umrikhina 2024-07-29 12:03:45 +04:00
parent b85b33bcc1
commit 43631a0f64
2 changed files with 25 additions and 2 deletions

View File

@ -41,7 +41,7 @@ import {
} from "@docspace/shared/api/settings/types";
import { TUser } from "@docspace/shared/api/people/types";
import { Encoder } from "@docspace/shared/utils/encoder";
import { TCreateUserData } from "@/types";
import { TCreateUserData, TTfaSecretKeyAndQR } from "@/types";
export const checkIsAuthenticated = async () => {
const [request] = createRequest(["/authentication"], [["", ""]], "GET");
@ -100,7 +100,7 @@ export async function getColorTheme() {
const res = await fetch(getSettings);
if (!res.ok) return;
if (!res.ok) throw new Error(res.statusText);
const colorTheme = await res.json();
@ -400,3 +400,19 @@ export async function ownerChange(
if (!res.ok) throw new Error(res.statusText);
}
export async function getTfaSecretKeyAndQR(confirmKey: string | null = null) {
const [getTfaSecretKeyAndQR] = createRequest(
[`/settings/tfaapp/setup`],
[confirmKey ? ["Confirm", confirmKey] : ["", ""]],
"GET",
);
const res = await fetch(getTfaSecretKeyAndQR);
if (!res.ok) throw new Error(res.statusText);
const tfaSecretKeyAndQR = await res.json();
return tfaSecretKeyAndQR.response as TTfaSecretKeyAndQR;
}

View File

@ -46,3 +46,10 @@ export const DEFAULT_SELECT_LANGUAGE: TCulturesOption = {
};
export const URL_LICENSE = "https://gnu.org/licenses/gpl-3.0.html";
export const TFA_ANDROID_APP_URL =
"https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2";
export const TFA_IOS_APP_URL =
"https://apps.apple.com/app/google-authenticator/id388497605";
export const TFA_WIN_APP_URL =
"https://www.microsoft.com/ru-ru/p/authenticator/9wzdncrfj3rj?rtc=1&activetab=pivot:overviewtab";