-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GL-25: Обновилены интеграции аутентификации
- Loading branch information
Терентьев Вадим Алексеевич
committed
May 4, 2024
1 parent
81fd28d
commit 8697349
Showing
22 changed files
with
358 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { AuthenticationFormAny } from "@/features/authentication-form-any/ui/AuthenticationFormAny"; |
44 changes: 44 additions & 0 deletions
44
src/features/authentication-form-any/ui/AuthenticationFormAny.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"use client"; | ||
|
||
import React from "react"; | ||
|
||
import { useEditIntegration } from "@/shared/hooks"; | ||
import { cn } from "@/shared/lib/utils"; | ||
import { Button } from "@/shared/ui/button"; | ||
import { Icons } from "@/shared/ui/icons"; | ||
import { AuthenticationType } from "@/shared/enums"; | ||
import { Alert, AlertDescription, AlertTitle } from "@/shared/ui/alert"; | ||
import { ExclamationTriangleIcon } from "@radix-ui/react-icons"; | ||
|
||
interface SignInFormProps extends React.HTMLAttributes<HTMLDivElement> { | ||
onOpenChange: (open: boolean) => void; | ||
} | ||
|
||
export function AuthenticationFormAny({ className, onOpenChange, ...props }: SignInFormProps) { | ||
const { mutateAsync, isPending } = useEditIntegration(); | ||
|
||
const onSubmit = async () => { | ||
await mutateAsync({ | ||
authType: AuthenticationType.AUTHENTICATION_TYPE_ANY, | ||
endpoint: "https://localhost", | ||
}).then(() => { | ||
onOpenChange(false); | ||
}); | ||
}; | ||
|
||
return ( | ||
<div className={cn("grid gap-4", className)} {...props}> | ||
<Alert variant="destructive"> | ||
<ExclamationTriangleIcon className="h-4 w-4" /> | ||
<AlertTitle>Внимание!</AlertTitle> | ||
<AlertDescription> | ||
Данный метод <strong>разрешит</strong> любую аутентификацию со стороны лаунчера | ||
</AlertDescription> | ||
</Alert> | ||
<Button type="submit" className="w-fit ml-auto" disabled={isPending} onClick={onSubmit}> | ||
{isPending && <Icons.spinner className="mr-2 h-4 w-4 animate-spin" />} | ||
Сохранить | ||
</Button> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { AuthenticationFormAzuriom } from "@/features/authentication-form-azuriom/ui/AuthenticationFormAzuriom"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { z } from "zod"; | ||
|
||
export const integrationSchema = z.object({ | ||
authType: z.number(), | ||
endpoint: z | ||
.string() | ||
.min(1, { message: "Вы не заполнили поле" }) | ||
.transform((v) => v.trim()), | ||
}); | ||
|
||
export type IntegrationFormSchemaType = z.infer<typeof integrationSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { AuthenticationFormDle } from "@/features/authentication-form-dle/ui/AuthenticationFormDle"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { z } from "zod"; | ||
|
||
export const integrationSchema = z.object({ | ||
authType: z.number(), | ||
endpoint: z | ||
.string() | ||
.min(1, { message: "Вы не заполнили поле" }) | ||
.transform((v) => v.trim()), | ||
}); | ||
|
||
export type IntegrationFormSchemaType = z.infer<typeof integrationSchema>; |
90 changes: 90 additions & 0 deletions
90
src/features/authentication-form-dle/ui/AuthenticationFormDle.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
"use client"; | ||
|
||
import React from "react"; | ||
|
||
import { SubmitHandler, useForm } from "react-hook-form"; | ||
|
||
import { zodResolver } from "@hookform/resolvers/zod"; | ||
import { useEditIntegration, useGetActiveAuthIntegrations } from "@/shared/hooks"; | ||
import { cn } from "@/shared/lib/utils"; | ||
import { Button } from "@/shared/ui/button"; | ||
import { | ||
Form, | ||
FormControl, | ||
FormDescription, | ||
FormItem, | ||
FormLabel, | ||
FormMessage, | ||
} from "@/shared/ui/form"; | ||
import { Icons } from "@/shared/ui/icons"; | ||
import { Input } from "@/shared/ui/input"; | ||
import { IntegrationFormSchemaType, integrationSchema } from "../lib/static"; | ||
import { AuthenticationType } from "@/shared/enums"; | ||
import Link from "next/link"; | ||
|
||
interface SignInFormProps extends React.HTMLAttributes<HTMLDivElement> { | ||
onOpenChange: (open: boolean) => void; | ||
} | ||
|
||
export function AuthenticationFormDle({ className, onOpenChange, ...props }: SignInFormProps) { | ||
const { data: integration } = useGetActiveAuthIntegrations(); | ||
|
||
const { mutateAsync, isPending } = useEditIntegration(); | ||
|
||
const form = useForm<IntegrationFormSchemaType>({ | ||
values: { | ||
endpoint: | ||
integration.authType === AuthenticationType.AUTHENTICATION_TYPE_DATALIFE_ENGINE | ||
? String(integration.endpoint) | ||
: "", | ||
authType: | ||
integration.authType === AuthenticationType.AUTHENTICATION_TYPE_DATALIFE_ENGINE | ||
? integration.authType | ||
: AuthenticationType.AUTHENTICATION_TYPE_DATALIFE_ENGINE, | ||
}, | ||
resolver: zodResolver(integrationSchema), | ||
}); | ||
|
||
const onSubmit: SubmitHandler<IntegrationFormSchemaType> = async ( | ||
data: IntegrationFormSchemaType, | ||
) => { | ||
await mutateAsync(data).then(() => { | ||
onOpenChange(false); | ||
}); | ||
}; | ||
|
||
return ( | ||
<div className={cn("grid gap-4", className)} {...props}> | ||
<Form {...form}> | ||
<form className="flex flex-col space-y-6" onSubmit={form.handleSubmit(onSubmit)}> | ||
<FormItem> | ||
<FormLabel>Введите эндпоинт</FormLabel> | ||
<FormControl> | ||
<Input placeholder="Введите эндпоинт" {...form.register("endpoint")} /> | ||
</FormControl> | ||
|
||
{form.formState.errors.endpoint ? ( | ||
<FormMessage>{form.formState.errors.endpoint.message}</FormMessage> | ||
) : ( | ||
<FormDescription> | ||
Не знаете где взять файл auth.php?{" "} | ||
<Link | ||
className="font-medium text-blue-600 dark:text-blue-500 hover:underline" | ||
href="https://stackoverflow.com/" | ||
passHref={true} | ||
target="_blank" | ||
> | ||
Скачайте по ссылке | ||
</Link> | ||
</FormDescription> | ||
)} | ||
</FormItem> | ||
<Button type="submit" className="w-fit ml-auto" disabled={isPending}> | ||
{isPending && <Icons.spinner className="mr-2 h-4 w-4 animate-spin" />} | ||
Сохранить | ||
</Button> | ||
</form> | ||
</Form> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { AuthenticationFormAzuriom } from "@/features/authentication-form-azuriom/ui/AuthenticationFormAzuriom"; |
48 changes: 48 additions & 0 deletions
48
src/features/authentication-form-undefined/ui/AuthenticationFormUndefined.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"use client"; | ||
|
||
import React from "react"; | ||
|
||
import { useEditIntegration } from "@/shared/hooks"; | ||
import { cn } from "@/shared/lib/utils"; | ||
import { Button } from "@/shared/ui/button"; | ||
import { Icons } from "@/shared/ui/icons"; | ||
import { AuthenticationType } from "@/shared/enums"; | ||
import { Alert, AlertDescription, AlertTitle } from "@/shared/ui/alert"; | ||
import { ExclamationTriangleIcon } from "@radix-ui/react-icons"; | ||
|
||
interface SignInFormProps extends React.HTMLAttributes<HTMLDivElement> { | ||
onOpenChange: (open: boolean) => void; | ||
} | ||
|
||
export function AuthenticationFormUndefined({ | ||
className, | ||
onOpenChange, | ||
...props | ||
}: SignInFormProps) { | ||
const { mutateAsync, isPending } = useEditIntegration(); | ||
|
||
const onSubmit = async () => { | ||
await mutateAsync({ | ||
authType: AuthenticationType.AUTHENTICATION_TYPE_UNDEFINED, | ||
endpoint: "https://localhost", | ||
}).then(() => { | ||
onOpenChange(false); | ||
}); | ||
}; | ||
|
||
return ( | ||
<div className={cn("grid gap-4", className)} {...props}> | ||
<Alert variant="destructive"> | ||
<ExclamationTriangleIcon className="h-4 w-4" /> | ||
<AlertTitle>Внимание!</AlertTitle> | ||
<AlertDescription> | ||
Данный метод <strong>запретит</strong> любую аутентификацию со стороны лаунчера | ||
</AlertDescription> | ||
</Alert> | ||
<Button type="submit" className="w-fit ml-auto" disabled={isPending} onClick={onSubmit}> | ||
{isPending && <Icons.spinner className="mr-2 h-4 w-4 animate-spin" />} | ||
Сохранить | ||
</Button> | ||
</div> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { IntegrationForm } from '@/features/integration-form/ui/IntegrationForm'; | ||
export { SentryConnectForm } from "@/features/sentry-connect-form/ui/SentryConnectForm"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './auth'; | ||
export * from './systems'; | ||
export * from "./auth"; | ||
export * from "./systems"; | ||
export * from "./integration"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export enum AuthenticationType { | ||
AUTHENTICATION_TYPE_UNDEFINED = 0, // Запрещена авторизация | ||
AUTHENTICATION_TYPE_DATALIFE_ENGINE = 1, // Авторизация через DLE | ||
AUTHENTICATION_TYPE_ANY = 2, // Разрешена авторизация под любым логином и паролем | ||
AUTHENTICATION_TYPE_AZURIOM = 3, // Разрешена авторизация под любым логином и паролем | ||
} | ||
|
||
export enum AuthenticationTypeOption { | ||
"OPTION_0" = "Undefined", // Запрещена авторизация | ||
"OPTION_1" = "DataLife Engine", // Авторизация через DLE | ||
"OPTION_2" = "Any", // Разрешена авторизация под любым логином и паролем | ||
"OPTION_3" = "Azuriom", // Разрешена авторизация под любым логином и паролем | ||
} |
Oops, something went wrong.