Skip to content

Commit

Permalink
Release v1.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
getcompass-opensource committed Apr 2, 2024
1 parent 0f07e45 commit b2e7b2b
Show file tree
Hide file tree
Showing 27 changed files with 1,415 additions and 831 deletions.
104 changes: 0 additions & 104 deletions join_web/web/dist/assets/index-3824270a.js

This file was deleted.

1 change: 1 addition & 0 deletions join_web/web/dist/assets/index-632ed746.css

Large diffs are not rendered by default.

107 changes: 107 additions & 0 deletions join_web/web/dist/assets/index-73cee61e.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion join_web/web/dist/assets/index-802f2cb4.css

This file was deleted.

4 changes: 2 additions & 2 deletions join_web/web/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAB8lBMVEUAAAD39/f5+fn19fX7+/v9/f3+/v7+/v74+Pj8/Pz+/v7x8fH////y8vL7+/v+/v79/f39/f3+/v739/f8/Pz+/v7/////+vf+tpP+s47/+PX+18X9YBT9XRD+0r39p3/8VAX9oXX/8+38dzv8UgX8czT/8On+0Lz7WRL7Ugf7Vw/+yrT9nnX7TgT7UQf9l2z//v7/7+n7bjP6TQT6Twf6TQX7ai3+7OT9ybT6Ug76TQf6UAv9w6v8lGv5SAP5Swb7jWL//fz+6+T6ZSz5RwT5SQb5SAT6YCb+5979wav4Sgr4Rwb4SQj8uqL7imL4QwL4RQb4RQX6g1n/+/r+5t74XCX3QgP3RAX4VyD+4tj8uKL3Qwf3QgX8sZn5gFj2PQH3QAX5eVD/+fj+4dj3Ux/2PQL2PgT2PQP3Txr93NH7r5j2PAT2PAP2OgH2OQH2OwP7qI/4dU/1NwD1OgT1OAH1Qg75hGH5h2X2RBD4b0f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mCC">
<link rel="icon" type="image/png" sizes="16x16" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA1VBMVEX6+vr9/f3+/v7////+/v7+/v7+/v7/////5tv/5tn//fv9kl/9j1r//Pr+5tz8ZiP8ZCD+5Nj9up77UAj6UAf9t5n/+/n7hVX5SQP7glH/+vj+4NX5Wh75RwT5RwX5WBz+3tL8r5T4RAX4RAT8rJD/+Pb5d0z3PgH3QQX5c0j/9/X92c73TBj2OwL2PQT2ShX91sr6o4r1NgD2RxT6nID6noP2SBb1NQD6n4X3akX2Viv8w7T//f38xrf2WC33Z0H/9vT/+vn7vKz939f94Nn7u6v/+fjK+klEAAAABnRSTlMNfej25v4j2d31AAAAAWJLR0QDEQxM8gAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAAAd0SU1FB+YCCg86MBGYSNMAAACTSURBVBjTY2BgZGKDAyZGBgZGZnYkwMzIwAJhcXBCaBYGVjDNxc3DC2awMrCBaT5+AUEwgw0qICQsIoosICYuISEphSQgLSMrJ6+AJKCopKSkrIIQUFVT19BQ19SCC2jr6Orp6eobwAUMjYxNTM3MLcACQIepWlpZ29jY2tk7gBwGdLqjkzPIPBdXN5DTMTyH7n0AjA4PYRZ3ZOYAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjItMDItMTBUMTU6NTg6NDgrMDA6MDCE25yOAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIyLTAyLTEwVDE1OjU4OjQ4KzAwOjAw9YYkMgAAAFd6VFh0UmF3IHByb2ZpbGUgdHlwZSBpcHRjAAB4nOPyDAhxVigoyk/LzEnlUgADIwsuYwsTIxNLkxQDEyBEgDTDZAMjs1Qgy9jUyMTMxBzEB8uASKBKLgDqFxF08kI1lQAAAABJRU5ErkJggg==">
<script src="https://www.google.com/recaptcha/enterprise.js" async defer></script>
<script type="module" crossorigin src="/assets/index-3824270a.js"></script>
<link rel="stylesheet" href="/assets/index-802f2cb4.css">
<script type="module" crossorigin src="/assets/index-73cee61e.js"></script>
<link rel="stylesheet" href="/assets/index-632ed746.css">
</head>
<body class="invisible-scrollbar">
<div id="path_preload_font" style="opacity: 0; position: absolute;">
Expand Down
6 changes: 4 additions & 2 deletions join_web/web/src/api/_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ export class LimitError extends Error {
}
}

export function useGetResponse() {
export type GET_RESPONSE_MODULE = "pivot" | "federation";

export function useGetResponse(module: GET_RESPONSE_MODULE) {

return async <T>(method: string, body: URLSearchParams, headerList: Record<string, string> = {}) => {

try {

const result = await ofetch<APIResponse<T>>(`/pivot/api/onpremiseweb/${method}/`, {
const result = await ofetch<APIResponse<T>>(`/${module}/api/onpremiseweb/${method}/`, {
method: "POST",
body,
headers: {
Expand Down
18 changes: 17 additions & 1 deletion join_web/web/src/api/_stores.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { atom, useAtomValue } from "jotai";
import { APIAuthInfo, APIJoinLinkInfo, Lang, PrepareJoinLinkErrorInfo } from "./_types.ts";
import {
APIAuthInfo,
APIJoinLinkInfo,
Lang,
PrepareJoinLinkErrorInfo,
AuthSsoInfo,
ApiGlobalStartDictionaryData,
ApiUserInfoData
} from "./_types.ts";
import { atomWithStorage } from "jotai/utils";
import { atomWithImmer } from "jotai-immer";
import { useMemo } from "react";
Expand All @@ -19,6 +27,8 @@ export const isPasswordChangedState = atom(false);
export const captchaPublicKeyState = atom("");

export const availableAuthMethodListState = atom<string[]>([]);
export const dictionaryDataState = atomWithImmer<ApiGlobalStartDictionaryData>({ auth_sso_start_button_text: "" });
export const userInfoDataState = atomWithImmer<ApiUserInfoData|null>(null);

export const isRegistrationState = atom(false);
export const firstAuthState = atom(false);
Expand All @@ -45,6 +55,7 @@ export const activeDialogIdState = atom("");
export const passwordInputState = atom("");
export const confirmPasswordState = atom("");
export const needShowForgotPasswordButtonState = atom(true);
export const isNeedShowCreateProfileDialogAfterSsoRegistrationState = atom(false);

export const confirmCodeState = atom<string[]>(Array(6).fill(""));

Expand All @@ -65,3 +76,8 @@ export const nameInputState = atomWithStorage<string>(
"name_input",
JSON.parse(localStorage.getItem("name_input") ?? '""')
);

export const authSsoState = atomWithStorage<AuthSsoInfo | null>(
"auth_sso_state",
JSON.parse(localStorage.getItem("auth_sso_state") ?? 'null')
)
20 changes: 20 additions & 0 deletions join_web/web/src/api/_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ export function getLangFullName(langCode: Lang): string {
return LANG_MAP[langCode] || "";
}

// словарь с текстами, возвращаемый в api-методе /global/start/
export type ApiGlobalStartDictionaryData = {
auth_sso_start_button_text: string,
}

// информация о пользователе, возвращаемая в различных api-методах
export type ApiUserInfoData = {
user_id: number,
full_name: string,
}

export const isValidEmail = (email: string): boolean => {
// регулярное выражение для проверки электронной почты
// это выражение проверяет, что email начинается с английских букв, цифр, точек, подчеркиваний или дефисов
Expand Down Expand Up @@ -126,3 +137,12 @@ export type APIResponse<T> = {
response: T;
status: "ok" | "error";
};

export type AuthSsoInfo = {
state: "none" | "in_progress",
data: {
link: string,
sso_auth_token: string,
signature: string,
}
}
4 changes: 2 additions & 2 deletions join_web/web/src/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import useIsJoinLink from "../lib/useIsJoinLink.ts";

export function useApiAuthLogout() {

const getResponse = useGetResponse();
const getResponse = useGetResponse("pivot");
const queryClient = useQueryClient();
const isJoinLink = useIsJoinLink();
const {navigateToPage} = useNavigatePage();
Expand Down Expand Up @@ -39,7 +39,7 @@ export type ApiAuthGenerateToken = {

export function useApiAuthGenerateToken(join_link_uniq?: string) {

const getResponse = useGetResponse();
const getResponse = useGetResponse("pivot");

return useQuery({

Expand Down
12 changes: 6 additions & 6 deletions join_web/web/src/api/auth/mail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type ApiAuthMailBegin = {
};

export function useApiAuthMailBegin() {
const getResponse = useGetResponse();
const getResponse = useGetResponse("pivot");

return useMutation({
retry: false,
Expand Down Expand Up @@ -57,7 +57,7 @@ export type ApiAuthMailConfirmShortAuthPassword = {
};

export function useApiAuthMailConfirmShortAuthPassword() {
const getResponse = useGetResponse();
const getResponse = useGetResponse("pivot");
const isJoinLink = useIsJoinLink();
const setAuth = useSetAtom(authState);
const setFirstAuth = useSetAtom(firstAuthState);
Expand Down Expand Up @@ -125,7 +125,7 @@ export type ApiAuthMailConfirmFullAuthPassword = {
};

export function useApiAuthMailConfirmFullAuthPassword() {
const getResponse = useGetResponse();
const getResponse = useGetResponse("pivot");
const setAuth = useSetAtom(authState);
const { navigateToDialog } = useNavigateDialog();

Expand Down Expand Up @@ -167,7 +167,7 @@ export type ApiAuthMailConfirmFullAuthCode = {
};

export function useApiAuthMailConfirmFullAuthCode() {
const getResponse = useGetResponse();
const getResponse = useGetResponse("pivot");
const isJoinLink = useIsJoinLink();
const setAuth = useSetAtom(authState);
const setFirstAuth = useSetAtom(firstAuthState);
Expand Down Expand Up @@ -235,7 +235,7 @@ export type ApiAuthMailResendFullAuthCode = {
};

export function useApiAuthMailResendFullAuthCode() {
const getResponse = useGetResponse();
const getResponse = useGetResponse("pivot");

return useMutation({
retry: false,
Expand All @@ -257,7 +257,7 @@ type ApiAuthMailCancelArgs = {
export type ApiAuthMailCancel = {};

export function useApiAuthMailCancel() {
const getResponse = useGetResponse();
const getResponse = useGetResponse("pivot");
const setAuth = useSetAtom(authState);
const setPasswordInput = useSetAtom(passwordInputState);
const setConfirmPassword = useSetAtom(confirmPasswordState);
Expand Down
6 changes: 3 additions & 3 deletions join_web/web/src/api/auth/phonenumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type ApiAuthPhoneNumberBegin = {

export function useApiAuthPhoneNumberBegin() {

const getResponse = useGetResponse();
const getResponse = useGetResponse("pivot");

return useMutation({

Expand Down Expand Up @@ -60,7 +60,7 @@ export type ApiAuthPhoneNumberConfirm = {

export function useApiAuthPhoneNumberConfirm() {

const getResponse = useGetResponse();
const getResponse = useGetResponse("pivot");
const isJoinLink = useIsJoinLink();
const setAuth = useSetAtom(authState)
const setFirstAuth = useSetAtom(firstAuthState);
Expand Down Expand Up @@ -114,7 +114,7 @@ type ApiAuthPhoneNumberRetryArgs = {

export function useApiAuthPhoneNumberRetry() {

const getResponse = useGetResponse();
const getResponse = useGetResponse("pivot");

return useMutation({

Expand Down
139 changes: 139 additions & 0 deletions join_web/web/src/api/auth/sso.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import { useGetResponse } from "../_index.ts";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useSetAtom } from "jotai/index";
import {
authSsoState,
authState,
firstAuthState,
isNeedShowCreateProfileDialogAfterSsoRegistrationState,
isRegistrationState,
userInfoDataState,
} from "../_stores.ts";
import { useNavigateDialog, useNavigatePage } from "../../components/hooks.ts";
import { ApiUserInfoData } from "../_types.ts";
import useIsJoinLink from "../../lib/useIsJoinLink.ts";

/* параметры api-метода federation/api/onpremiseweb/sso/auth/begin */
export type ApiFederationSsoAuthBeginArgs = {
redirect_url: string;
};

/* структура ответа api-метода federation/api/onpremiseweb/sso/auth/begin */
export type ApiFederationSsoAuthBegin = {
link: string;
sso_auth_token: string;
signature: string;
};

export function useApiFederationSsoAuthBegin() {
const getResponse = useGetResponse("federation");

return useMutation({
retry: false,
networkMode: "always",
mutationFn: async ({ redirect_url }: ApiFederationSsoAuthBeginArgs) => {
const body = new URLSearchParams({
redirect_url: redirect_url,
});
return getResponse<ApiFederationSsoAuthBegin>("sso/auth/begin", body, {});
},
});
}

/* параметры api-метода federation/api/onpremiseweb/sso/auth/getStatus */
export type ApiFederationSsoAuthGetStatusArgs = {
sso_auth_token: string;
signature: string;
};

/* структура ответа api-метода federation/api/onpremiseweb/sso/auth/getStatus */
export type ApiFederationSsoAuthGetStatus = {
status: "wait" | "expired" | "ready" | "completed";
};

export function useApiFederationSsoAuthGetStatus() {
const getResponse = useGetResponse("federation");

return useMutation({
retry: false,
networkMode: "always",
mutationFn: async ({ sso_auth_token, signature }: ApiFederationSsoAuthGetStatusArgs) => {
const body = new URLSearchParams({
sso_auth_token: sso_auth_token,
signature: signature,
});
return getResponse<ApiFederationSsoAuthGetStatus>("sso/auth/getStatus", body, {});
},
});
}

/* параметры api-метода pivot/api/onpremiseweb/auth/sso/begin */
export type ApiPivotAuthSsoBeginArgs = {
sso_auth_token: string;
signature: string;
join_link?: string;
};

/* структура ответа api-метода pivot/api/onpremiseweb/auth/sso/begin */
export type ApiPivotAuthSsoBegin = {
authentication_token: string;
need_fill_profile: 0 | 1;
user_info: ApiUserInfoData;
};

export function useApiPivotAuthSsoBegin() {
const getResponse = useGetResponse("pivot");
const setAuth = useSetAtom(authState);
const setAuthSso = useSetAtom(authSsoState);
const setFirstAuth = useSetAtom(firstAuthState);
const setUserInfoDataState = useSetAtom(userInfoDataState);
const setIsNeedShowCreateProfileDialogAfterSsoRegistration = useSetAtom(
isNeedShowCreateProfileDialogAfterSsoRegistrationState
);
const setRegistrationState = useSetAtom(isRegistrationState);
const queryClient = useQueryClient();
const isJoinLink = useIsJoinLink();
const { navigateToDialog } = useNavigateDialog();
const { navigateToPage } = useNavigatePage();

return useMutation({
retry: false,
networkMode: "always",
mutationFn: async ({ sso_auth_token, signature, join_link }: ApiPivotAuthSsoBeginArgs) => {
const body = new URLSearchParams({
sso_auth_token: sso_auth_token,
signature: signature,
});

if (join_link !== undefined && /join\/[a-zA-Z0-9]+\/?/.test(join_link)) {
body.append("join_link", join_link);
}

return getResponse<ApiPivotAuthSsoBegin>("auth/sso/begin", body, {});
},

async onSuccess(response) {
if (response.need_fill_profile === 1) {
setRegistrationState(true);
setIsNeedShowCreateProfileDialogAfterSsoRegistration(true);
}

await queryClient.invalidateQueries({ queryKey: ["global/start"] });
if (isJoinLink) {
await queryClient.invalidateQueries({ queryKey: ["joinlink/prepare", window.location.href] });
}

setFirstAuth(true);
setAuth(null);
setAuthSso(null);
setUserInfoDataState(response.user_info);

if (response.need_fill_profile === 1) {
navigateToPage("auth");
navigateToDialog("auth_create_profile");
} else {
navigateToPage("token");
}
},
});
}
12 changes: 10 additions & 2 deletions join_web/web/src/api/global.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import {useQuery} from "@tanstack/react-query";
import {ofetch} from "ofetch";
import {APIResponse} from "./_types.ts";
import {APIResponse, ApiGlobalStartDictionaryData, ApiUserInfoData} from "./_types.ts";
import {useSetAtom} from "jotai";
import {availableAuthMethodListState, captchaPublicKeyState, profileState} from "./_stores.ts";
import {availableAuthMethodListState, captchaPublicKeyState, profileState, dictionaryDataState, userInfoDataState} from "./_stores.ts";

type ApiGlobalDoStart = {
is_authorized: number,
need_fill_profile: number,
captcha_public_key: string,
available_auth_method_list: string[],
dictionary: ApiGlobalStartDictionaryData
user_info: ApiUserInfoData|null
}

export function useApiGlobalDoStart() {

const setProfile = useSetAtom(profileState);
const setCaptchaPublicKey = useSetAtom(captchaPublicKeyState);
const setAvailableAuthMethodList = useSetAtom(availableAuthMethodListState);
const setStartDictionaryDataState = useSetAtom(dictionaryDataState);
const setUserInfoDataState = useSetAtom(userInfoDataState);

return useQuery({

Expand All @@ -33,6 +37,10 @@ export function useApiGlobalDoStart() {

setAvailableAuthMethodList(result.response.available_auth_method_list);

setStartDictionaryDataState(result.response.dictionary)

setUserInfoDataState(result.response.user_info)

setProfile({
is_authorized: result.response.is_authorized === 1,
need_fill_profile: result.response.need_fill_profile === 1,
Expand Down
4 changes: 2 additions & 2 deletions join_web/web/src/api/joinlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type ApiJoinLinkPrepare = {
};

export function useApiJoinLinkPrepare(raw_join_link: string) {
const getResponse = useGetResponse();
const getResponse = useGetResponse("pivot");

return useQuery({
retry: false,
Expand All @@ -33,7 +33,7 @@ type ApiJoinLinkAcceptArgs = {
};

export function useApiJoinLinkAccept() {
const getResponse = useGetResponse();
const getResponse = useGetResponse("pivot");

return useMutation({
retry: false,
Expand Down
Loading

0 comments on commit b2e7b2b

Please sign in to comment.