apps/web: always show telegram bot link for ldap-tfa
This commit is contained in:
parent
2d41e403ce
commit
4eaf62da0b
@ -11,7 +11,7 @@ const { TELEGRAM_BOT_URL } = publicRuntimeConfig;
|
|||||||
export function BaseForm({ children, onSubmit }: FormProps & PropsWithChildren) {
|
export function BaseForm({ children, onSubmit }: FormProps & PropsWithChildren) {
|
||||||
const { handleSubmit, register } = useForm<FormData>();
|
const { handleSubmit, register } = useForm<FormData>();
|
||||||
const {
|
const {
|
||||||
state: { error, step },
|
state: { error, step, tfa },
|
||||||
} = useContext(FormStateContext);
|
} = useContext(FormStateContext);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -32,7 +32,7 @@ export function BaseForm({ children, onSubmit }: FormProps & PropsWithChildren)
|
|||||||
autoComplete="on"
|
autoComplete="on"
|
||||||
{...register('password', { required: true })}
|
{...register('password', { required: true })}
|
||||||
/>
|
/>
|
||||||
{step === 'telegram-login' ? (
|
{tfa ? (
|
||||||
<a target="_blank" className="info" href={TELEGRAM_BOT_URL} rel="noreferrer">
|
<a target="_blank" className="info" href={TELEGRAM_BOT_URL} rel="noreferrer">
|
||||||
Открыть чат с ботом
|
Открыть чат с ботом
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import { createContext, useMemo, useReducer } from 'react';
|
|||||||
type State = {
|
type State = {
|
||||||
error: string | undefined;
|
error: string | undefined;
|
||||||
step: 'login' | 'telegram' | 'telegram-login';
|
step: 'login' | 'telegram' | 'telegram-login';
|
||||||
|
tfa: boolean;
|
||||||
user: LdapUser | undefined;
|
user: LdapUser | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -59,13 +60,15 @@ type Context = {
|
|||||||
export const FormStateContext = createContext<Context>({} as Context);
|
export const FormStateContext = createContext<Context>({} as Context);
|
||||||
|
|
||||||
type FormStateProviderProps = {
|
type FormStateProviderProps = {
|
||||||
|
readonly tfa: boolean;
|
||||||
readonly user?: LdapUser;
|
readonly user?: LdapUser;
|
||||||
} & PropsWithChildren;
|
} & PropsWithChildren;
|
||||||
|
|
||||||
export function FormStateProvider({ children, user = undefined }: FormStateProviderProps) {
|
export function FormStateProvider({ children, tfa, user = undefined }: FormStateProviderProps) {
|
||||||
const [state, dispatch] = useReducer(reducer, {
|
const [state, dispatch] = useReducer(reducer, {
|
||||||
error: undefined,
|
error: undefined,
|
||||||
step: 'login',
|
step: 'login',
|
||||||
|
tfa,
|
||||||
user,
|
user,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user