@vitnode/core 1.2.0-canary.60 → 1.2.0-canary.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/scripts/get-config.js +15 -0
- package/dist/scripts/plugin.js +188 -0
- package/dist/scripts/prepare-database.js +177 -0
- package/dist/scripts/prepare-plugins-files.js +134 -0
- package/dist/scripts/run-interactive-shell-command.js +21 -0
- package/dist/scripts/scripts.js +39 -13
- package/dist/scripts/shared/file-utils.js +203 -0
- package/dist/src/api/adapters/sso/discord.js +1 -77
- package/dist/src/api/adapters/sso/facebook.js +1 -76
- package/dist/src/api/adapters/sso/google.js +1 -87
- package/dist/src/api/config.js +1 -67
- package/dist/src/api/lib/check-plugin-id.js +1 -43
- package/dist/src/api/lib/cron.js +1 -22
- package/dist/src/api/lib/logger-middleware.js +1 -35
- package/dist/src/api/lib/module.js +1 -22
- package/dist/src/api/lib/plugin.js +1 -22
- package/dist/src/api/lib/route.js +1 -27
- package/dist/src/api/lib/with-pagination.js +1 -83
- package/dist/src/api/middlewares/captcha.middleware.js +1 -63
- package/dist/src/api/middlewares/cron-auth.middleware.js +1 -19
- package/dist/src/api/middlewares/global.middleware.js +1 -93
- package/dist/src/api/middlewares/rate-limiter.middleware.js +1 -32
- package/dist/src/api/models/device.js +1 -61
- package/dist/src/api/models/email.js +1 -76
- package/dist/src/api/models/password.js +1 -36
- package/dist/src/api/models/session-admin.js +1 -106
- package/dist/src/api/models/session.js +1 -85
- package/dist/src/api/models/sso.js +1 -120
- package/dist/src/api/models/user/get-user-by-id.js +1 -19
- package/dist/src/api/models/user/sign-in-with-passwords.js +1 -22
- package/dist/src/api/models/user/sign-up.js +1 -73
- package/dist/src/api/models/user.js +1 -8
- package/dist/src/api/modules/admin/admin.module.js +1 -19
- package/dist/src/api/modules/admin/advanced/advanced.admin.module.js +1 -11
- package/dist/src/api/modules/admin/advanced/cron/cron.admin.module.js +1 -12
- package/dist/src/api/modules/admin/advanced/cron/routes/get.route.js +1 -66
- package/dist/src/api/modules/admin/advanced/cron/routes/run.route.js +1 -95
- package/dist/src/api/modules/admin/debug/debug.admin.module.js +1 -10
- package/dist/src/api/modules/admin/debug/routes/logs.route.js +1 -94
- package/dist/src/api/modules/admin/routes/session.route.js +1 -47
- package/dist/src/api/modules/admin/users/routes/list.route.js +1 -79
- package/dist/src/api/modules/admin/users/routes/users.route.js +1 -84
- package/dist/src/api/modules/admin/users/users.admin.module.js +1 -10
- package/dist/src/api/modules/cron/cron/clean.cron.js +1 -24
- package/dist/src/api/modules/cron/cron.module.js +1 -14
- package/dist/src/api/modules/cron/helpers/process-cron-jobs.d.ts.map +1 -1
- package/dist/src/api/modules/cron/helpers/process-cron-jobs.js +1 -76
- package/dist/src/api/modules/cron/routes/cron.route.js +1 -101
- package/dist/src/api/modules/middleware/middleware.module.js +1 -10
- package/dist/src/api/modules/middleware/route.js +1 -49
- package/dist/src/api/modules/users/avatar-color.js +1 -43
- package/dist/src/api/modules/users/routes/change-password.route.js +1 -58
- package/dist/src/api/modules/users/routes/reset-passowrd.route.js +1 -91
- package/dist/src/api/modules/users/routes/session.route.js +1 -46
- package/dist/src/api/modules/users/routes/sign-in.route.js +1 -71
- package/dist/src/api/modules/users/routes/sign-out.route.js +1 -43
- package/dist/src/api/modules/users/routes/sign-up.route.js +1 -77
- package/dist/src/api/modules/users/routes/test.route.js +1 -33
- package/dist/src/api/modules/users/sso/routes/callback.route.js +1 -52
- package/dist/src/api/modules/users/sso/routes/create-url.route.js +1 -36
- package/dist/src/api/modules/users/sso/sso.module.js +1 -12
- package/dist/src/api/modules/users/users.module.js +1 -26
- package/dist/src/api/plugin.js +1 -15
- package/dist/src/app/login/page.js +1 -16
- package/dist/src/app/login/reset-password/page.js +1 -18
- package/dist/src/app/login/sso/[providerId]/page.js +1 -10
- package/dist/src/app/register/page.js +1 -16
- package/dist/src/app_admin/core/advanced/cron/page.js +1 -42
- package/dist/src/app_admin/core/debug/page.js +1 -45
- package/dist/src/app_admin/core/page.js +1 -5
- package/dist/src/app_admin/core/test/page.js +1 -5
- package/dist/src/app_admin/core/users/page.js +1 -38
- package/dist/src/components/avatar.js +1 -14
- package/dist/src/components/confirm-action/confirm-action-alert-dialog.js +1 -42
- package/dist/src/components/confirm-action/content.js +1 -31
- package/dist/src/components/date-format.js +1 -41
- package/dist/src/components/form/auto-form.js +1 -103
- package/dist/src/components/form/common/desc.js +1 -9
- package/dist/src/components/form/common/label.js +1 -18
- package/dist/src/components/form/fields/checkbox.js +1 -37
- package/dist/src/components/form/fields/combobox-async.js +1 -123
- package/dist/src/components/form/fields/combobox.js +1 -87
- package/dist/src/components/form/fields/input.js +1 -39
- package/dist/src/components/form/fields/radio-group.js +1 -50
- package/dist/src/components/form/fields/select.js +1 -58
- package/dist/src/components/form/fields/switch.js +1 -36
- package/dist/src/components/form/fields/textarea.js +1 -36
- package/dist/src/components/i18n-provider.js +1 -43
- package/dist/src/components/logo-vitnode.js +1 -119
- package/dist/src/components/switchers/langs/language-switcher.js +1 -47
- package/dist/src/components/switchers/themes/theme-switcher.js +1 -28
- package/dist/src/components/table/content.js +1 -81
- package/dist/src/components/table/data-table.js +1 -68
- package/dist/src/components/table/order-table-head.js +1 -50
- package/dist/src/components/table/pagination.js +1 -122
- package/dist/src/components/tiptap/extension.js +1 -33
- package/dist/src/components/tiptap/toolbar/actions/alignment-action.js +1 -91
- package/dist/src/components/tiptap/toolbar/actions/bold-action.js +1 -39
- package/dist/src/components/tiptap/toolbar/actions/headings-action.js +1 -93
- package/dist/src/components/tiptap/toolbar/actions/italic-action.js +1 -38
- package/dist/src/components/tiptap/toolbar/actions/list-action.js +1 -61
- package/dist/src/components/tiptap/toolbar/actions/text-format-more/text-format-more.js +1 -59
- package/dist/src/components/tiptap/toolbar/actions/underline-action.js +1 -38
- package/dist/src/components/tiptap/toolbar/actions/undo-redo-actions.js +1 -63
- package/dist/src/components/tiptap/toolbar/actions/utils/tooltip-shortcut.js +1 -11
- package/dist/src/components/tiptap/toolbar/tiptap-toolbar.js +1 -55
- package/dist/src/components/tiptap/toolbar/use-toolbar-editor.js +1 -5
- package/dist/src/components/ui/accordion.js +1 -46
- package/dist/src/components/ui/alert-dialog.js +1 -123
- package/dist/src/components/ui/alert.js +1 -39
- package/dist/src/components/ui/badge.js +1 -28
- package/dist/src/components/ui/button-client.js +1 -57
- package/dist/src/components/ui/button.js +1 -32
- package/dist/src/components/ui/card.js +1 -52
- package/dist/src/components/ui/checkbox.js +1 -20
- package/dist/src/components/ui/collapsible.js +1 -22
- package/dist/src/components/ui/command.js +1 -98
- package/dist/src/components/ui/context-menu.js +1 -140
- package/dist/src/components/ui/dialog.js +1 -189
- package/dist/src/components/ui/drawer.js +1 -83
- package/dist/src/components/ui/dropdown-menu.js +1 -141
- package/dist/src/components/ui/editor-content.js +1 -10
- package/dist/src/components/ui/editor.js +1 -35
- package/dist/src/components/ui/form.js +1 -148
- package/dist/src/components/ui/header-content.js +1 -30
- package/dist/src/components/ui/hover-card.js +1 -29
- package/dist/src/components/ui/input-otp.js +1 -48
- package/dist/src/components/ui/input.js +1 -11
- package/dist/src/components/ui/label.js +1 -12
- package/dist/src/components/ui/loader.js +1 -16
- package/dist/src/components/ui/menubar.js +1 -151
- package/dist/src/components/ui/navigation-menu.js +1 -82
- package/dist/src/components/ui/popover.js +1 -35
- package/dist/src/components/ui/progress.js +1 -19
- package/dist/src/components/ui/radio-group.js +1 -27
- package/dist/src/components/ui/scroll-area.js +1 -33
- package/dist/src/components/ui/select.js +1 -113
- package/dist/src/components/ui/separator.js +1 -14
- package/dist/src/components/ui/sheet.js +1 -92
- package/dist/src/components/ui/sidebar.js +1 -433
- package/dist/src/components/ui/skeleton.js +1 -10
- package/dist/src/components/ui/slider.js +1 -50
- package/dist/src/components/ui/sonner.js +1 -26
- package/dist/src/components/ui/switch.js +1 -16
- package/dist/src/components/ui/table.js +1 -63
- package/dist/src/components/ui/tabs.js +1 -33
- package/dist/src/components/ui/textarea.js +1 -10
- package/dist/src/components/ui/toggle-group.js +1 -45
- package/dist/src/components/ui/toggle.js +1 -34
- package/dist/src/components/ui/tooltip.js +1 -57
- package/dist/src/config.js +1 -4
- package/dist/src/database/admins.js +1 -74
- package/dist/src/database/cron.js +1 -22
- package/dist/src/database/languages.js +1 -52
- package/dist/src/database/logs.js +1 -34
- package/dist/src/database/moderators.js +1 -37
- package/dist/src/database/roles.js +1 -13
- package/dist/src/database/sessions.js +1 -60
- package/dist/src/database/users.js +1 -145
- package/dist/src/drizzle.config.js +1 -67
- package/dist/src/emails/default-template.js +1 -99
- package/dist/src/emails/reset-password.js +1 -132
- package/dist/src/emails/ui/button.js +1 -36
- package/dist/src/emails/ui/card.js +1 -39
- package/dist/src/hooks/use-before-unload.js +1 -30
- package/dist/src/hooks/use-captcha.js +1 -122
- package/dist/src/hooks/use-mobile.js +1 -16
- package/dist/src/lib/api/get-middleware-api.js +1 -13
- package/dist/src/lib/api/get-next-cron-run-date.js +1 -14
- package/dist/src/lib/api/get-next-cron-run-date.test.js +1 -55
- package/dist/src/lib/api/get-session-admin-api.js +1 -19
- package/dist/src/lib/api/get-session-api.js +1 -14
- package/dist/src/lib/api/should-cron-job-run.js +1 -16
- package/dist/src/lib/api/should-cron-job-run.test.js +1 -213
- package/dist/src/lib/api/validate-cron-schedule.d.ts +2 -0
- package/dist/src/lib/api/validate-cron-schedule.d.ts.map +1 -0
- package/dist/src/lib/api/validate-cron-schedule.js +1 -0
- package/dist/src/lib/api/validate-cron-schedule.test.d.ts +2 -0
- package/dist/src/lib/api/validate-cron-schedule.test.d.ts.map +1 -0
- package/dist/src/lib/api/validate-cron-schedule.test.js +1 -0
- package/dist/src/lib/colors.js +1 -140
- package/dist/src/lib/colors.test.js +1 -173
- package/dist/src/lib/config.js +1 -14
- package/dist/src/lib/ctrl-or-command-character.js +1 -5
- package/dist/src/lib/fetcher/cookie-from-string-to-object.js +1 -12
- package/dist/src/lib/fetcher/cookie-from-string-to-object.test.js +1 -78
- package/dist/src/lib/fetcher/core.js +3 -48
- package/dist/src/lib/fetcher/helpers-server.js +1 -18
- package/dist/src/lib/fetcher/helpers.js +1 -16
- package/dist/src/lib/fetcher/helpers.test.js +1 -37
- package/dist/src/lib/fetcher/types.js +1 -1
- package/dist/src/lib/fetcher-client.js +1 -17
- package/dist/src/lib/fetcher.js +1 -33
- package/dist/src/lib/helpers/auto-form.js +1 -98
- package/dist/src/lib/helpers/auto-form.test.js +1 -336
- package/dist/src/lib/navigation.js +1 -11
- package/dist/src/lib/plugin.js +1 -3
- package/dist/src/lib/special-characters.js +1 -4
- package/dist/src/lib/special-characters.test.js +1 -56
- package/dist/src/lib/utils.js +1 -5
- package/dist/src/locales/en.json +308 -0
- package/dist/src/tests/setup.js +1 -6
- package/dist/src/views/admin/layouts/admin-layout.js +1 -73
- package/dist/src/views/admin/layouts/sidebar/nav/item.js +1 -98
- package/dist/src/views/admin/layouts/sidebar/nav/nav.js +1 -60
- package/dist/src/views/admin/layouts/sidebar/sidebar.js +1 -28
- package/dist/src/views/admin/layouts/sidebar/sign-out.js +1 -14
- package/dist/src/views/admin/layouts/user-bar/client.js +1 -69
- package/dist/src/views/admin/layouts/user-bar/user-bar.js +1 -32
- package/dist/src/views/admin/sign-in/sign-in-admin-view.js +1 -27
- package/dist/src/views/admin/views/core/advanced/cron/cron-table-view.js +1 -97
- package/dist/src/views/admin/views/core/advanced/cron/run-action/mutation-api.js +1 -23
- package/dist/src/views/admin/views/core/advanced/cron/run-action/run-action.js +1 -38
- package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.js +1 -44
- package/dist/src/views/admin/views/core/debug/actions/clear-cache/clear-cache.js +1 -35
- package/dist/src/views/admin/views/core/debug/actions/clear-cache/mutation-api.js +1 -5
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/content.js +1 -281
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/more.js +1 -67
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-status.js +1 -14
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-type-log.js +1 -30
- package/dist/src/views/admin/views/core/debug/system-logs/system-logs-view.js +1 -96
- package/dist/src/views/admin/views/core/test.js +1 -161
- package/dist/src/views/admin/views/core/users/users-admin-view.js +1 -89
- package/dist/src/views/auth/password-reset/change-password-form/form.js +1 -48
- package/dist/src/views/auth/password-reset/change-password-form/mutation-api.js +1 -22
- package/dist/src/views/auth/password-reset/change-password-form/use-form.js +1 -36
- package/dist/src/views/auth/password-reset/form/form.js +1 -104
- package/dist/src/views/auth/password-reset/form/mutation-api.js +1 -21
- package/dist/src/views/auth/password-reset/form/use-form.js +1 -33
- package/dist/src/views/auth/password-reset/password-reset-view.js +1 -37
- package/dist/src/views/auth/sign-in/form/form.js +1 -64
- package/dist/src/views/auth/sign-in/form/mutation-api.js +1 -33
- package/dist/src/views/auth/sign-in/form/use-form.js +1 -38
- package/dist/src/views/auth/sign-in/sign-in-view.js +1 -61
- package/dist/src/views/auth/sign-up/components/password-input.js +1 -96
- package/dist/src/views/auth/sign-up/email-confirmation-view.js +1 -55
- package/dist/src/views/auth/sign-up/form/form.js +1 -89
- package/dist/src/views/auth/sign-up/form/mutation-api.js +1 -30
- package/dist/src/views/auth/sign-up/form/use-form.js +1 -70
- package/dist/src/views/auth/sign-up/sign-up-view.js +1 -65
- package/dist/src/views/auth/sign-up/wrapper.js +1 -22
- package/dist/src/views/auth/sso/buttons/client.js +1 -22
- package/dist/src/views/auth/sso/buttons/mutation-api.js +1 -24
- package/dist/src/views/auth/sso/buttons/sso-buttons.js +1 -56
- package/dist/src/views/auth/sso/callback/callback-sso-view.js +1 -32
- package/dist/src/views/auth/sso/callback/client/client.js +1 -68
- package/dist/src/views/auth/sso/callback/client/mutation-api.js +1 -32
- package/dist/src/views/error/back-button.js +1 -14
- package/dist/src/views/error/error-view.js +1 -58
- package/dist/src/views/error/global-error-view.js +1 -50
- package/dist/src/views/layouts/provider.js +1 -44
- package/dist/src/views/layouts/root-layout.js +1 -25
- package/dist/src/views/layouts/theme/header/header.js +1 -38
- package/dist/src/views/layouts/theme/header/user/auth/auth.js +1 -33
- package/dist/src/views/layouts/theme/header/user/auth/client.js +1 -47
- package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.js +1 -27
- package/dist/src/views/layouts/theme/header/user/user.js +1 -32
- package/dist/src/views/layouts/theme/layout.js +1 -16
- package/dist/src/vitnode.config.js +1 -42
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/tsup.config.js +18 -0
- package/dist/vitest.config.d.ts.map +1 -1
- package/dist/vitest.config.js +49 -0
- package/eslint.config.mjs +2 -0
- package/package.json +6 -10
- package/dist/src/api/adapters/cron/node-cron.adapter.d.ts +0 -3
- package/dist/src/api/adapters/cron/node-cron.adapter.d.ts.map +0 -1
- package/dist/src/api/adapters/cron/node-cron.adapter.js +0 -11
- package/dist/src/api/adapters/email/nodemailer.d.ts +0 -10
- package/dist/src/api/adapters/email/nodemailer.d.ts.map +0 -1
- package/dist/src/api/adapters/email/nodemailer.js +0 -30
- package/dist/src/api/adapters/email/resend.d.ts +0 -6
- package/dist/src/api/adapters/email/resend.d.ts.map +0 -1
- package/dist/src/api/adapters/email/resend.js +0 -21
|
@@ -1,64 +1 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { AlertCircle } from "lucide-react";
|
|
4
|
-
import { useTranslations } from "next-intl";
|
|
5
|
-
import { AutoForm } from "../../../../components/form/auto-form.js";
|
|
6
|
-
import { AutoFormInput } from "../../../../components/form/fields/input.js";
|
|
7
|
-
import { Alert, AlertDescription, AlertTitle } from "../../../../components/ui/alert.js";
|
|
8
|
-
import { Link } from "../../../../lib/navigation.js";
|
|
9
|
-
import { useFormSignIn } from "./use-form.js";
|
|
10
|
-
export const FormSignIn = ({ isAdmin, isEmail })=>{
|
|
11
|
-
const t = useTranslations("core.auth.sign_in");
|
|
12
|
-
const { onSubmit, error, formSchema } = useFormSignIn({
|
|
13
|
-
isAdmin
|
|
14
|
-
});
|
|
15
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
16
|
-
className: "space-y-4",
|
|
17
|
-
children: [
|
|
18
|
-
error && /*#__PURE__*/ _jsxs(Alert, {
|
|
19
|
-
variant: "destructive",
|
|
20
|
-
children: [
|
|
21
|
-
/*#__PURE__*/ _jsx(AlertCircle, {
|
|
22
|
-
className: "size-4"
|
|
23
|
-
}),
|
|
24
|
-
/*#__PURE__*/ _jsx(AlertTitle, {
|
|
25
|
-
children: t(`errors.${error}.title`)
|
|
26
|
-
}),
|
|
27
|
-
/*#__PURE__*/ _jsx(AlertDescription, {
|
|
28
|
-
children: t(`errors.${error}.desc`)
|
|
29
|
-
})
|
|
30
|
-
]
|
|
31
|
-
}),
|
|
32
|
-
/*#__PURE__*/ _jsx(AutoForm, {
|
|
33
|
-
fields: [
|
|
34
|
-
{
|
|
35
|
-
id: "email",
|
|
36
|
-
component: (props)=>/*#__PURE__*/ _jsx(AutoFormInput, {
|
|
37
|
-
label: t("email.label"),
|
|
38
|
-
...props
|
|
39
|
-
})
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
id: "password",
|
|
43
|
-
component: (props)=>/*#__PURE__*/ _jsx(AutoFormInput, {
|
|
44
|
-
label: t("password.label"),
|
|
45
|
-
labelRight: isEmail ? /*#__PURE__*/ _jsx(Link, {
|
|
46
|
-
className: "text-primary hover:underline",
|
|
47
|
-
href: "/login/reset-password",
|
|
48
|
-
children: t("password.reset")
|
|
49
|
-
}) : undefined,
|
|
50
|
-
type: "password",
|
|
51
|
-
...props
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
],
|
|
55
|
-
formSchema: formSchema,
|
|
56
|
-
onSubmit: onSubmit,
|
|
57
|
-
submitButtonProps: {
|
|
58
|
-
className: "w-full",
|
|
59
|
-
children: t("submit")
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
]
|
|
63
|
-
});
|
|
64
|
-
};
|
|
1
|
+
"use client";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{AlertCircle}from"lucide-react";import{useTranslations}from"next-intl";import{AutoForm}from"../../../../components/form/auto-form.js";import{AutoFormInput}from"../../../../components/form/fields/input.js";import{Alert,AlertDescription,AlertTitle}from"../../../../components/ui/alert.js";import{Link}from"../../../../lib/navigation.js";import{useFormSignIn}from"./use-form.js";export const FormSignIn=({isAdmin,isEmail})=>{const t=useTranslations("core.auth.sign_in");const{onSubmit,error,formSchema}=useFormSignIn({isAdmin});return _jsxs("div",{className:"space-y-4",children:[error&&_jsxs(Alert,{variant:"destructive",children:[_jsx(AlertCircle,{className:"size-4"}),_jsx(AlertTitle,{children:t(`errors.${error}.title`)}),_jsx(AlertDescription,{children:t(`errors.${error}.desc`)})]}),_jsx(AutoForm,{fields:[{id:"email",component:props=>_jsx(AutoFormInput,{label:t("email.label"),...props})},{id:"password",component:props=>_jsx(AutoFormInput,{label:t("password.label"),labelRight:isEmail?_jsx(Link,{className:"text-primary hover:underline",href:"/login/reset-password",children:t("password.reset")}):undefined,type:"password",...props})}],formSchema:formSchema,onSubmit:onSubmit,submitButtonProps:{className:"w-full",children:t("submit")}})]})};
|
|
@@ -1,33 +1 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
import { revalidatePath } from "next/cache";
|
|
3
|
-
import { usersModule } from "../../../../api/modules/users/users.module.js";
|
|
4
|
-
import { fetcher } from "../../../../lib/fetcher.js";
|
|
5
|
-
import { redirect } from "../../../../lib/navigation.js";
|
|
6
|
-
export const mutationApi = async (input)=>{
|
|
7
|
-
const res = await fetcher(usersModule, {
|
|
8
|
-
path: "/sign_in",
|
|
9
|
-
method: "post",
|
|
10
|
-
module: "users",
|
|
11
|
-
allowSaveCookies: true,
|
|
12
|
-
args: {
|
|
13
|
-
body: input
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
if (res.status === 403) {
|
|
17
|
-
return {
|
|
18
|
-
message: "access_denied"
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
if (res.status !== 201) {
|
|
22
|
-
return {
|
|
23
|
-
message: "Internal Server Error"
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
if (input.isAdmin) {
|
|
27
|
-
revalidatePath("/[locale]/admin", "layout");
|
|
28
|
-
await redirect("/admin/core");
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
revalidatePath("/[locale]/(main)", "layout");
|
|
32
|
-
await redirect("/");
|
|
33
|
-
};
|
|
1
|
+
"use server";import{revalidatePath}from"next/cache";import{usersModule}from"../../../../api/modules/users/users.module.js";import{fetcher}from"../../../../lib/fetcher.js";import{redirect}from"../../../../lib/navigation.js";export const mutationApi=async input=>{const res=await fetcher(usersModule,{path:"/sign_in",method:"post",module:"users",allowSaveCookies:true,args:{body:input}});if(res.status===403){return{message:"access_denied"}}if(res.status!==201){return{message:"Internal Server Error"}}if(input.isAdmin){revalidatePath("/[locale]/admin","layout");await redirect("/admin/core");return}revalidatePath("/[locale]/(main)","layout");await redirect("/")};
|
|
@@ -1,38 +1 @@
|
|
|
1
|
-
import { useTranslations }
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { toast } from "sonner";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { mutationApi } from "./mutation-api.js";
|
|
6
|
-
export const useFormSignIn = ({ isAdmin = false })=>{
|
|
7
|
-
const [error, setError] = React.useState("");
|
|
8
|
-
const t = useTranslations("core.auth.sign_in");
|
|
9
|
-
const tErrors = useTranslations("core.global.errors");
|
|
10
|
-
const formSchema = z.object({
|
|
11
|
-
email: z.email({
|
|
12
|
-
message: t("email.invalid")
|
|
13
|
-
}).default(""),
|
|
14
|
-
password: z.string().min(1, {
|
|
15
|
-
message: t("password.required")
|
|
16
|
-
}).default("")
|
|
17
|
-
});
|
|
18
|
-
const onSubmit = async (values)=>{
|
|
19
|
-
setError("");
|
|
20
|
-
const mutation = await mutationApi({
|
|
21
|
-
...values,
|
|
22
|
-
isAdmin
|
|
23
|
-
});
|
|
24
|
-
if (!mutation?.message) return;
|
|
25
|
-
if (mutation?.message !== "Internal Server Error") {
|
|
26
|
-
setError(mutation.message);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
toast.error(tErrors("title"), {
|
|
30
|
-
description: tErrors("internal_server_error")
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
return {
|
|
34
|
-
onSubmit,
|
|
35
|
-
error,
|
|
36
|
-
formSchema
|
|
37
|
-
};
|
|
38
|
-
};
|
|
1
|
+
import{useTranslations}from"next-intl";import React from"react";import{toast}from"sonner";import{z}from"zod";import{mutationApi}from"./mutation-api.js";export const useFormSignIn=({isAdmin=false})=>{const[error,setError]=React.useState("");const t=useTranslations("core.auth.sign_in");const tErrors=useTranslations("core.global.errors");const formSchema=z.object({email:z.email({message:t("email.invalid")}).default(""),password:z.string().min(1,{message:t("password.required")}).default("")});const onSubmit=async values=>{setError("");const mutation=await mutationApi({...values,isAdmin});if(!mutation?.message)return;if(mutation?.message!=="Internal Server Error"){setError(mutation.message);return}toast.error(tErrors("title"),{description:tErrors("internal_server_error")})};return{onSubmit,error,formSchema}};
|
|
@@ -1,61 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getTranslations } from "next-intl/server";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { Card, CardDescription } from "../../../components/ui/card.js";
|
|
5
|
-
import { getMiddlewareApi } from "../../../lib/api/get-middleware-api.js";
|
|
6
|
-
import { Link } from "../../../lib/navigation.js";
|
|
7
|
-
import { I18nProvider } from "../../../components/i18n-provider.js";
|
|
8
|
-
import { SSOButtons, SSOButtonsSkeleton } from "../sso/buttons/sso-buttons.js";
|
|
9
|
-
import { FormSignIn } from "./form/form.js";
|
|
10
|
-
export const SignInView = async ()=>{
|
|
11
|
-
const [t, tGlobal, { isEmail }] = await Promise.all([
|
|
12
|
-
getTranslations("core.auth.sign_in"),
|
|
13
|
-
getTranslations("core.global"),
|
|
14
|
-
getMiddlewareApi()
|
|
15
|
-
]);
|
|
16
|
-
return /*#__PURE__*/ _jsx(I18nProvider, {
|
|
17
|
-
namespaces: "core.auth.sign_in",
|
|
18
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
19
|
-
className: "mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col justify-center px-4 py-16",
|
|
20
|
-
children: /*#__PURE__*/ _jsxs(Card, {
|
|
21
|
-
className: "bg-muted gap-0 p-0",
|
|
22
|
-
children: [
|
|
23
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
24
|
-
className: "bg-card rounded-xl p-6",
|
|
25
|
-
children: [
|
|
26
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
27
|
-
className: "mb-10 space-y-2 text-center",
|
|
28
|
-
children: [
|
|
29
|
-
/*#__PURE__*/ _jsx("h1", {
|
|
30
|
-
className: "text-2xl leading-none font-semibold tracking-tight",
|
|
31
|
-
children: tGlobal("login")
|
|
32
|
-
}),
|
|
33
|
-
/*#__PURE__*/ _jsx(CardDescription, {
|
|
34
|
-
children: t("desc")
|
|
35
|
-
})
|
|
36
|
-
]
|
|
37
|
-
}),
|
|
38
|
-
/*#__PURE__*/ _jsx(FormSignIn, {
|
|
39
|
-
isEmail: isEmail
|
|
40
|
-
}),
|
|
41
|
-
/*#__PURE__*/ _jsx(React.Suspense, {
|
|
42
|
-
fallback: /*#__PURE__*/ _jsx(SSOButtonsSkeleton, {}),
|
|
43
|
-
children: /*#__PURE__*/ _jsx(SSOButtons, {})
|
|
44
|
-
})
|
|
45
|
-
]
|
|
46
|
-
}),
|
|
47
|
-
/*#__PURE__*/ _jsx("div", {
|
|
48
|
-
className: "text-accent-foreground p-6 text-center text-sm",
|
|
49
|
-
children: t.rich("do_not_have_account", {
|
|
50
|
-
link: (text)=>/*#__PURE__*/ _jsx(Link, {
|
|
51
|
-
className: "text-primary font-semibold",
|
|
52
|
-
href: "/register",
|
|
53
|
-
children: text
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
})
|
|
57
|
-
]
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
});
|
|
61
|
-
};
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{getTranslations}from"next-intl/server";import React from"react";import{Card,CardDescription}from"../../../components/ui/card.js";import{getMiddlewareApi}from"../../../lib/api/get-middleware-api.js";import{Link}from"../../../lib/navigation.js";import{I18nProvider}from"../../../components/i18n-provider.js";import{SSOButtons,SSOButtonsSkeleton}from"../sso/buttons/sso-buttons.js";import{FormSignIn}from"./form/form.js";export const SignInView=async()=>{const[t,tGlobal,{isEmail}]=await Promise.all([getTranslations("core.auth.sign_in"),getTranslations("core.global"),getMiddlewareApi()]);return _jsx(I18nProvider,{namespaces:"core.auth.sign_in",children:_jsx("div",{className:"mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col justify-center px-4 py-16",children:_jsxs(Card,{className:"bg-muted gap-0 p-0",children:[_jsxs("div",{className:"bg-card rounded-xl p-6",children:[_jsxs("div",{className:"mb-10 space-y-2 text-center",children:[_jsx("h1",{className:"text-2xl leading-none font-semibold tracking-tight",children:tGlobal("login")}),_jsx(CardDescription,{children:t("desc")})]}),_jsx(FormSignIn,{isEmail:isEmail}),_jsx(React.Suspense,{fallback:_jsx(SSOButtonsSkeleton,{}),children:_jsx(SSOButtons,{})})]}),_jsx("div",{className:"text-accent-foreground p-6 text-center text-sm",children:t.rich("do_not_have_account",{link:text=>_jsx(Link,{className:"text-primary font-semibold",href:"/register",children:text})})})]})})})};
|
|
@@ -1,96 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CheckIcon, XIcon } from "lucide-react";
|
|
3
|
-
import { useTranslations } from "next-intl";
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { AutoFormLabel } from "../../../../components/form/common/label.js";
|
|
6
|
-
import { FormControl, FormItem, FormMessage } from "../../../../components/ui/form.js";
|
|
7
|
-
import { Input } from "../../../../components/ui/input.js";
|
|
8
|
-
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../../../../components/ui/tooltip.js";
|
|
9
|
-
export const PasswordInput = ({ label, // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
|
-
description: _, field, otherProps: { maxLength, minLength, pattern }, ...props })=>{
|
|
11
|
-
const t = useTranslations("core.auth.sign_up");
|
|
12
|
-
const [openTooltip, setOpenTooltip] = React.useState(false);
|
|
13
|
-
const value = field.value ?? "";
|
|
14
|
-
const regexArray = [
|
|
15
|
-
{
|
|
16
|
-
regex: /^.{8,}$/.test(value),
|
|
17
|
-
id: "min_length"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
regex: /[A-Z]/.test(value),
|
|
21
|
-
id: "uppercase"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
regex: /\d/.test(value),
|
|
25
|
-
id: "number"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
regex: /\W|_/.test(value),
|
|
29
|
-
id: "special_char"
|
|
30
|
-
}
|
|
31
|
-
];
|
|
32
|
-
return /*#__PURE__*/ _jsxs(FormItem, {
|
|
33
|
-
children: [
|
|
34
|
-
/*#__PURE__*/ _jsx(AutoFormLabel, {
|
|
35
|
-
children: label
|
|
36
|
-
}),
|
|
37
|
-
/*#__PURE__*/ _jsx(TooltipProvider, {
|
|
38
|
-
delayDuration: 0,
|
|
39
|
-
children: /*#__PURE__*/ _jsxs(Tooltip, {
|
|
40
|
-
open: openTooltip,
|
|
41
|
-
children: [
|
|
42
|
-
/*#__PURE__*/ _jsx(TooltipTrigger, {
|
|
43
|
-
asChild: true,
|
|
44
|
-
children: /*#__PURE__*/ _jsx(FormControl, {
|
|
45
|
-
children: /*#__PURE__*/ _jsx(Input, {
|
|
46
|
-
type: "password",
|
|
47
|
-
...field,
|
|
48
|
-
maxLength: maxLength ?? props.maxLength,
|
|
49
|
-
minLength: minLength ?? props.minLength,
|
|
50
|
-
onBlur: (e)=>{
|
|
51
|
-
setOpenTooltip(false);
|
|
52
|
-
field.onBlur();
|
|
53
|
-
props.onBlur?.(e);
|
|
54
|
-
},
|
|
55
|
-
onChange: (e)=>{
|
|
56
|
-
setOpenTooltip(true);
|
|
57
|
-
field.onChange(e);
|
|
58
|
-
props.onChange?.(e);
|
|
59
|
-
},
|
|
60
|
-
pattern: pattern ?? props.pattern,
|
|
61
|
-
value: field.value ?? "",
|
|
62
|
-
...props
|
|
63
|
-
})
|
|
64
|
-
})
|
|
65
|
-
}),
|
|
66
|
-
/*#__PURE__*/ _jsxs(TooltipContent, {
|
|
67
|
-
className: "flex flex-col gap-2 text-sm",
|
|
68
|
-
sideOffset: 8,
|
|
69
|
-
children: [
|
|
70
|
-
/*#__PURE__*/ _jsx("span", {
|
|
71
|
-
className: "text-based font-semibold",
|
|
72
|
-
children: t("password.requirements.label")
|
|
73
|
-
}),
|
|
74
|
-
/*#__PURE__*/ _jsx("ul", {
|
|
75
|
-
className: "space-y-1",
|
|
76
|
-
children: regexArray.map(({ regex, id })=>/*#__PURE__*/ _jsxs("li", {
|
|
77
|
-
className: "flex items-center gap-1",
|
|
78
|
-
children: [
|
|
79
|
-
regex ? /*#__PURE__*/ _jsx(CheckIcon, {
|
|
80
|
-
className: "size-4"
|
|
81
|
-
}) : /*#__PURE__*/ _jsx(XIcon, {
|
|
82
|
-
className: "size-4"
|
|
83
|
-
}),
|
|
84
|
-
t(`password.requirements.${id}`)
|
|
85
|
-
]
|
|
86
|
-
}, id))
|
|
87
|
-
})
|
|
88
|
-
]
|
|
89
|
-
})
|
|
90
|
-
]
|
|
91
|
-
})
|
|
92
|
-
}),
|
|
93
|
-
/*#__PURE__*/ _jsx(FormMessage, {})
|
|
94
|
-
]
|
|
95
|
-
});
|
|
96
|
-
};
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{CheckIcon,XIcon}from"lucide-react";import{useTranslations}from"next-intl";import React from"react";import{AutoFormLabel}from"../../../../components/form/common/label.js";import{FormControl,FormItem,FormMessage}from"../../../../components/ui/form.js";import{Input}from"../../../../components/ui/input.js";import{Tooltip,TooltipContent,TooltipProvider,TooltipTrigger}from"../../../../components/ui/tooltip.js";export const PasswordInput=({label,description:_,field,otherProps:{maxLength,minLength,pattern},...props})=>{const t=useTranslations("core.auth.sign_up");const[openTooltip,setOpenTooltip]=React.useState(false);const value=field.value??"";const regexArray=[{regex:/^.{8,}$/.test(value),id:"min_length"},{regex:/[A-Z]/.test(value),id:"uppercase"},{regex:/\d/.test(value),id:"number"},{regex:/\W|_/.test(value),id:"special_char"}];return _jsxs(FormItem,{children:[_jsx(AutoFormLabel,{children:label}),_jsx(TooltipProvider,{delayDuration:0,children:_jsxs(Tooltip,{open:openTooltip,children:[_jsx(TooltipTrigger,{asChild:true,children:_jsx(FormControl,{children:_jsx(Input,{type:"password",...field,maxLength:maxLength??props.maxLength,minLength:minLength??props.minLength,onBlur:e=>{setOpenTooltip(false);field.onBlur();props.onBlur?.(e)},onChange:e=>{setOpenTooltip(true);field.onChange(e);props.onChange?.(e)},pattern:pattern??props.pattern,value:field.value??"",...props})})}),_jsxs(TooltipContent,{className:"flex flex-col gap-2 text-sm",sideOffset:8,children:[_jsx("span",{className:"text-based font-semibold",children:t("password.requirements.label")}),_jsx("ul",{className:"space-y-1",children:regexArray.map(({regex,id})=>_jsxs("li",{className:"flex items-center gap-1",children:[regex?_jsx(CheckIcon,{className:"size-4"}):_jsx(XIcon,{className:"size-4"}),t(`password.requirements.${id}`)]},id))})]})]})}),_jsx(FormMessage,{})]})};
|
|
@@ -1,55 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Mail, MailboxIcon } from "lucide-react";
|
|
3
|
-
import { useTranslations } from "next-intl";
|
|
4
|
-
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "../../../components/ui/card.js";
|
|
5
|
-
export const EmailConfirmationView = ({ email })=>{
|
|
6
|
-
const t = useTranslations("core.auth.sign_up.email_confirmation");
|
|
7
|
-
return /*#__PURE__*/ _jsxs(Card, {
|
|
8
|
-
className: "w-full max-w-md p-6",
|
|
9
|
-
children: [
|
|
10
|
-
/*#__PURE__*/ _jsxs(CardHeader, {
|
|
11
|
-
className: "text-center",
|
|
12
|
-
children: [
|
|
13
|
-
/*#__PURE__*/ _jsx("div", {
|
|
14
|
-
className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-green-100 dark:bg-green-900",
|
|
15
|
-
children: /*#__PURE__*/ _jsx(MailboxIcon, {
|
|
16
|
-
className: "h-8 w-8 text-green-600 dark:text-green-400"
|
|
17
|
-
})
|
|
18
|
-
}),
|
|
19
|
-
/*#__PURE__*/ _jsx(CardTitle, {
|
|
20
|
-
className: "text-2xl font-bold",
|
|
21
|
-
children: t("title")
|
|
22
|
-
}),
|
|
23
|
-
/*#__PURE__*/ _jsx(CardDescription, {
|
|
24
|
-
className: "text-base",
|
|
25
|
-
children: t("desc")
|
|
26
|
-
})
|
|
27
|
-
]
|
|
28
|
-
}),
|
|
29
|
-
/*#__PURE__*/ _jsxs(CardContent, {
|
|
30
|
-
className: "space-y-6",
|
|
31
|
-
children: [
|
|
32
|
-
/*#__PURE__*/ _jsx("div", {
|
|
33
|
-
className: "bg-muted rounded-lg p-4",
|
|
34
|
-
children: /*#__PURE__*/ _jsxs("div", {
|
|
35
|
-
className: "flex items-center gap-3",
|
|
36
|
-
children: [
|
|
37
|
-
/*#__PURE__*/ _jsx("span", {
|
|
38
|
-
className: "text-sm font-medium",
|
|
39
|
-
children: email
|
|
40
|
-
}),
|
|
41
|
-
/*#__PURE__*/ _jsx(Mail, {
|
|
42
|
-
className: "text-muted-foreground ml-auto size-5"
|
|
43
|
-
})
|
|
44
|
-
]
|
|
45
|
-
})
|
|
46
|
-
}),
|
|
47
|
-
/*#__PURE__*/ _jsx("p", {
|
|
48
|
-
className: "text-muted-foreground text-center text-sm",
|
|
49
|
-
children: t("check_spam")
|
|
50
|
-
})
|
|
51
|
-
]
|
|
52
|
-
})
|
|
53
|
-
]
|
|
54
|
-
});
|
|
55
|
-
};
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Mail,MailboxIcon}from"lucide-react";import{useTranslations}from"next-intl";import{Card,CardContent,CardDescription,CardHeader,CardTitle}from"../../../components/ui/card.js";export const EmailConfirmationView=({email})=>{const t=useTranslations("core.auth.sign_up.email_confirmation");return _jsxs(Card,{className:"w-full max-w-md p-6",children:[_jsxs(CardHeader,{className:"text-center",children:[_jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-green-100 dark:bg-green-900",children:_jsx(MailboxIcon,{className:"h-8 w-8 text-green-600 dark:text-green-400"})}),_jsx(CardTitle,{className:"text-2xl font-bold",children:t("title")}),_jsx(CardDescription,{className:"text-base",children:t("desc")})]}),_jsxs(CardContent,{className:"space-y-6",children:[_jsx("div",{className:"bg-muted rounded-lg p-4",children:_jsxs("div",{className:"flex items-center gap-3",children:[_jsx("span",{className:"text-sm font-medium",children:email}),_jsx(Mail,{className:"text-muted-foreground ml-auto size-5"})]})}),_jsx("p",{className:"text-muted-foreground text-center text-sm",children:t("check_spam")})]})]})};
|
|
@@ -1,89 +1 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useTranslations } from "next-intl";
|
|
4
|
-
import { AutoForm } from "../../../../components/form/auto-form.js";
|
|
5
|
-
import { AutoFormCheckbox } from "../../../../components/form/fields/checkbox.js";
|
|
6
|
-
import { AutoFormInput } from "../../../../components/form/fields/input.js";
|
|
7
|
-
import { Link } from "../../../../lib/navigation.js";
|
|
8
|
-
import { removeSpecialCharacters } from "../../../../lib/special-characters.js";
|
|
9
|
-
import { PasswordInput } from "../components/password-input.js";
|
|
10
|
-
import { useFormSignUp } from "./use-form.js";
|
|
11
|
-
export const FormSignUp = ({ isEmail, captcha })=>{
|
|
12
|
-
const t = useTranslations("core.auth.sign_up");
|
|
13
|
-
const { onSubmit, formSchema } = useFormSignUp();
|
|
14
|
-
return /*#__PURE__*/ _jsx(AutoForm, {
|
|
15
|
-
captcha: captcha,
|
|
16
|
-
fields: [
|
|
17
|
-
{
|
|
18
|
-
id: "name",
|
|
19
|
-
component: ({ field, ...props })=>{
|
|
20
|
-
const value = field.value ?? "";
|
|
21
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
22
|
-
className: "space-y-2",
|
|
23
|
-
children: [
|
|
24
|
-
/*#__PURE__*/ _jsx(AutoFormInput, {
|
|
25
|
-
field: field,
|
|
26
|
-
label: t("username.label"),
|
|
27
|
-
...props
|
|
28
|
-
}),
|
|
29
|
-
value.length >= 3 && /*#__PURE__*/ _jsx("div", {
|
|
30
|
-
className: "text-muted-foreground text-sm",
|
|
31
|
-
children: t.rich("username.your_user_code", {
|
|
32
|
-
code: ()=>/*#__PURE__*/ _jsx("span", {
|
|
33
|
-
className: "text-foreground",
|
|
34
|
-
children: removeSpecialCharacters(value)
|
|
35
|
-
})
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
]
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
id: "email",
|
|
44
|
-
component: (props)=>/*#__PURE__*/ _jsx(AutoFormInput, {
|
|
45
|
-
label: t("email.label"),
|
|
46
|
-
...props
|
|
47
|
-
})
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
id: "password",
|
|
51
|
-
component: (props)=>/*#__PURE__*/ _jsx(PasswordInput, {
|
|
52
|
-
label: t("password.label"),
|
|
53
|
-
...props
|
|
54
|
-
})
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: "terms",
|
|
58
|
-
component: (props)=>/*#__PURE__*/ _jsx(AutoFormCheckbox, {
|
|
59
|
-
...props,
|
|
60
|
-
description: t.rich("terms.desc", {
|
|
61
|
-
link: (text)=>/*#__PURE__*/ _jsx(Link, {
|
|
62
|
-
className: "text-primary",
|
|
63
|
-
href: "/terms",
|
|
64
|
-
children: text
|
|
65
|
-
})
|
|
66
|
-
}),
|
|
67
|
-
label: t("terms.label")
|
|
68
|
-
})
|
|
69
|
-
},
|
|
70
|
-
...isEmail ? [
|
|
71
|
-
{
|
|
72
|
-
id: "newsletter",
|
|
73
|
-
component: (props)=>/*#__PURE__*/ _jsx(AutoFormCheckbox, {
|
|
74
|
-
...props,
|
|
75
|
-
description: t("newsletter.desc"),
|
|
76
|
-
label: t("newsletter.label")
|
|
77
|
-
})
|
|
78
|
-
}
|
|
79
|
-
] : []
|
|
80
|
-
],
|
|
81
|
-
formSchema: formSchema,
|
|
82
|
-
mode: "all",
|
|
83
|
-
onSubmit: onSubmit,
|
|
84
|
-
submitButtonProps: {
|
|
85
|
-
className: "w-full",
|
|
86
|
-
children: t("submit")
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
};
|
|
1
|
+
"use client";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useTranslations}from"next-intl";import{AutoForm}from"../../../../components/form/auto-form.js";import{AutoFormCheckbox}from"../../../../components/form/fields/checkbox.js";import{AutoFormInput}from"../../../../components/form/fields/input.js";import{Link}from"../../../../lib/navigation.js";import{removeSpecialCharacters}from"../../../../lib/special-characters.js";import{PasswordInput}from"../components/password-input.js";import{useFormSignUp}from"./use-form.js";export const FormSignUp=({isEmail,captcha})=>{const t=useTranslations("core.auth.sign_up");const{onSubmit,formSchema}=useFormSignUp();return _jsx(AutoForm,{captcha:captcha,fields:[{id:"name",component:({field,...props})=>{const value=field.value??"";return _jsxs("div",{className:"space-y-2",children:[_jsx(AutoFormInput,{field:field,label:t("username.label"),...props}),value.length>=3&&_jsx("div",{className:"text-muted-foreground text-sm",children:t.rich("username.your_user_code",{code:()=>_jsx("span",{className:"text-foreground",children:removeSpecialCharacters(value)})})})]})}},{id:"email",component:props=>_jsx(AutoFormInput,{label:t("email.label"),...props})},{id:"password",component:props=>_jsx(PasswordInput,{label:t("password.label"),...props})},{id:"terms",component:props=>_jsx(AutoFormCheckbox,{...props,description:t.rich("terms.desc",{link:text=>_jsx(Link,{className:"text-primary",href:"/terms",children:text})}),label:t("terms.label")})},...isEmail?[{id:"newsletter",component:props=>_jsx(AutoFormCheckbox,{...props,description:t("newsletter.desc"),label:t("newsletter.label")})}]:[]],formSchema:formSchema,mode:"all",onSubmit:onSubmit,submitButtonProps:{className:"w-full",children:t("submit")}})};
|
|
@@ -1,30 +1 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
import { revalidatePath } from "next/cache";
|
|
3
|
-
import { usersModule } from "../../../../api/modules/users/users.module.js";
|
|
4
|
-
import { fetcher } from "../../../../lib/fetcher.js";
|
|
5
|
-
import { redirect } from "../../../../lib/navigation.js";
|
|
6
|
-
export const mutationApi = async ({ captchaToken, ...input })=>{
|
|
7
|
-
const res = await fetcher(usersModule, {
|
|
8
|
-
path: "/sign_up",
|
|
9
|
-
method: "post",
|
|
10
|
-
module: "users",
|
|
11
|
-
allowSaveCookies: true,
|
|
12
|
-
captchaToken,
|
|
13
|
-
args: {
|
|
14
|
-
body: input
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
if (res.status !== 201) {
|
|
18
|
-
return {
|
|
19
|
-
error: await res.text()
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
const data = await res.json();
|
|
23
|
-
if (data.emailVerified) {
|
|
24
|
-
revalidatePath("/[locale]/(main)", "layout");
|
|
25
|
-
await redirect("/");
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
data
|
|
29
|
-
};
|
|
30
|
-
};
|
|
1
|
+
"use server";import{revalidatePath}from"next/cache";import{usersModule}from"../../../../api/modules/users/users.module.js";import{fetcher}from"../../../../lib/fetcher.js";import{redirect}from"../../../../lib/navigation.js";export const mutationApi=async({captchaToken,...input})=>{const res=await fetcher(usersModule,{path:"/sign_up",method:"post",module:"users",allowSaveCookies:true,captchaToken,args:{body:input}});if(res.status!==201){return{error:await res.text()}}const data=await res.json();if(data.emailVerified){revalidatePath("/[locale]/(main)","layout");await redirect("/")}return{data}};
|
|
@@ -1,70 +1 @@
|
|
|
1
|
-
import { useTranslations
|
|
2
|
-
import { toast } from "sonner";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { useWrapperSignUp } from "../wrapper.js";
|
|
5
|
-
import { mutationApi } from "./mutation-api.js";
|
|
6
|
-
export const usePasswordZodSchema = ()=>{
|
|
7
|
-
const t = useTranslations("core.auth.sign_up");
|
|
8
|
-
const tError = useTranslations("core.global.errors");
|
|
9
|
-
const invalidPassword = t("password.invalid");
|
|
10
|
-
return z.string({
|
|
11
|
-
message: tError("field_required")
|
|
12
|
-
}).regex(/^.{8,}$/, invalidPassword).regex(/[A-Z]/, invalidPassword).regex(/\d/, invalidPassword).regex(/\W|_/, invalidPassword).default("");
|
|
13
|
-
};
|
|
14
|
-
export const useFormSignUp = ()=>{
|
|
15
|
-
const t = useTranslations("core.auth.sign_up");
|
|
16
|
-
const tError = useTranslations("core.global.errors");
|
|
17
|
-
const passwordSchema = usePasswordZodSchema();
|
|
18
|
-
const formSchema = z.object({
|
|
19
|
-
name: z.string({
|
|
20
|
-
message: tError("field_required")
|
|
21
|
-
}).min(3, t("username.min_length")).max(32, t("username.max_length")).default(""),
|
|
22
|
-
// .refine(value => nameRegex.test(value), t('name.invalid'))
|
|
23
|
-
email: z.email({
|
|
24
|
-
message: t("email.invalid")
|
|
25
|
-
}).default("test@test.com"),
|
|
26
|
-
password: passwordSchema,
|
|
27
|
-
terms: z.boolean().refine((value)=>value, t("terms.required")).default(false),
|
|
28
|
-
newsletter: z.boolean().default(false).optional()
|
|
29
|
-
});
|
|
30
|
-
const { setSendingEmail } = useWrapperSignUp();
|
|
31
|
-
const onSubmit = async (values, form, { captchaToken })=>{
|
|
32
|
-
const mutation = await mutationApi({
|
|
33
|
-
...values,
|
|
34
|
-
captchaToken
|
|
35
|
-
});
|
|
36
|
-
if (mutation.data) {
|
|
37
|
-
if (!mutation.data.emailVerified) {
|
|
38
|
-
setSendingEmail(mutation.data.email);
|
|
39
|
-
}
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const errorMessages = {
|
|
43
|
-
"Email already exists": {
|
|
44
|
-
field: "email",
|
|
45
|
-
message: t("email.exists")
|
|
46
|
-
},
|
|
47
|
-
"Name already exists": {
|
|
48
|
-
field: "name",
|
|
49
|
-
message: t("username.exists")
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const errorConfig = errorMessages[mutation.error];
|
|
53
|
-
if (errorConfig) {
|
|
54
|
-
form.setError(errorConfig.field, {
|
|
55
|
-
type: "manual",
|
|
56
|
-
message: errorConfig.message
|
|
57
|
-
}, {
|
|
58
|
-
shouldFocus: true
|
|
59
|
-
});
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
toast.error(tError("title"), {
|
|
63
|
-
description: tError("internal_server_error")
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
return {
|
|
67
|
-
onSubmit,
|
|
68
|
-
formSchema
|
|
69
|
-
};
|
|
70
|
-
};
|
|
1
|
+
import{useTranslations}from"next-intl";import{toast}from"sonner";import{z}from"zod";import{useWrapperSignUp}from"../wrapper.js";import{mutationApi}from"./mutation-api.js";export const usePasswordZodSchema=()=>{const t=useTranslations("core.auth.sign_up");const tError=useTranslations("core.global.errors");const invalidPassword=t("password.invalid");return z.string({message:tError("field_required")}).regex(/^.{8,}$/,invalidPassword).regex(/[A-Z]/,invalidPassword).regex(/\d/,invalidPassword).regex(/\W|_/,invalidPassword).default("")};export const useFormSignUp=()=>{const t=useTranslations("core.auth.sign_up");const tError=useTranslations("core.global.errors");const passwordSchema=usePasswordZodSchema();const formSchema=z.object({name:z.string({message:tError("field_required")}).min(3,t("username.min_length")).max(32,t("username.max_length")).default(""),email:z.email({message:t("email.invalid")}).default("test@test.com"),password:passwordSchema,terms:z.boolean().refine(value=>value,t("terms.required")).default(false),newsletter:z.boolean().default(false).optional()});const{setSendingEmail}=useWrapperSignUp();const onSubmit=async(values,form,{captchaToken})=>{const mutation=await mutationApi({...values,captchaToken});if(mutation.data){if(!mutation.data.emailVerified){setSendingEmail(mutation.data.email)}return}const errorMessages={"Email already exists":{field:"email",message:t("email.exists")},"Name already exists":{field:"name",message:t("username.exists")}};const errorConfig=errorMessages[mutation.error];if(errorConfig){form.setError(errorConfig.field,{type:"manual",message:errorConfig.message},{shouldFocus:true});return}toast.error(tError("title"),{description:tError("internal_server_error")})};return{onSubmit,formSchema}};
|
|
@@ -1,65 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getTranslations } from "next-intl/server";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { Card, CardDescription } from "../../../components/ui/card.js";
|
|
5
|
-
import { getMiddlewareApi } from "../../../lib/api/get-middleware-api.js";
|
|
6
|
-
import { Link } from "../../../lib/navigation.js";
|
|
7
|
-
import { I18nProvider } from "../../../components/i18n-provider.js";
|
|
8
|
-
import { SSOButtons, SSOButtonsSkeleton } from "../sso/buttons/sso-buttons.js";
|
|
9
|
-
import { FormSignUp } from "./form/form.js";
|
|
10
|
-
import { WrapperSignUp } from "./wrapper.js";
|
|
11
|
-
export const SignUpView = async ()=>{
|
|
12
|
-
const [t, tGlobal, { isEmail, captcha }] = await Promise.all([
|
|
13
|
-
getTranslations("core.auth.sign_up"),
|
|
14
|
-
getTranslations("core.global"),
|
|
15
|
-
getMiddlewareApi()
|
|
16
|
-
]);
|
|
17
|
-
return /*#__PURE__*/ _jsx(I18nProvider, {
|
|
18
|
-
namespaces: "core.auth.sign_up",
|
|
19
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
20
|
-
className: "mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col justify-center px-4 py-16",
|
|
21
|
-
children: /*#__PURE__*/ _jsx(WrapperSignUp, {
|
|
22
|
-
children: /*#__PURE__*/ _jsxs(Card, {
|
|
23
|
-
className: "bg-muted gap-0 p-0",
|
|
24
|
-
children: [
|
|
25
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
26
|
-
className: "bg-card rounded-xl p-6",
|
|
27
|
-
children: [
|
|
28
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
29
|
-
className: "mb-10 space-y-2 text-center",
|
|
30
|
-
children: [
|
|
31
|
-
/*#__PURE__*/ _jsx("h1", {
|
|
32
|
-
className: "text-2xl leading-none font-semibold tracking-tight",
|
|
33
|
-
children: tGlobal("register")
|
|
34
|
-
}),
|
|
35
|
-
/*#__PURE__*/ _jsx(CardDescription, {
|
|
36
|
-
children: t("desc")
|
|
37
|
-
})
|
|
38
|
-
]
|
|
39
|
-
}),
|
|
40
|
-
/*#__PURE__*/ _jsx(FormSignUp, {
|
|
41
|
-
captcha: captcha,
|
|
42
|
-
isEmail: isEmail
|
|
43
|
-
}),
|
|
44
|
-
/*#__PURE__*/ _jsx(React.Suspense, {
|
|
45
|
-
fallback: /*#__PURE__*/ _jsx(SSOButtonsSkeleton, {}),
|
|
46
|
-
children: /*#__PURE__*/ _jsx(SSOButtons, {})
|
|
47
|
-
})
|
|
48
|
-
]
|
|
49
|
-
}),
|
|
50
|
-
/*#__PURE__*/ _jsx("div", {
|
|
51
|
-
className: "text-accent-foreground p-6 text-center text-sm",
|
|
52
|
-
children: t.rich("already_have_account", {
|
|
53
|
-
link: (text)=>/*#__PURE__*/ _jsx(Link, {
|
|
54
|
-
className: "text-primary font-semibold",
|
|
55
|
-
href: "/login",
|
|
56
|
-
children: text
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
]
|
|
61
|
-
})
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
});
|
|
65
|
-
};
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{getTranslations}from"next-intl/server";import React from"react";import{Card,CardDescription}from"../../../components/ui/card.js";import{getMiddlewareApi}from"../../../lib/api/get-middleware-api.js";import{Link}from"../../../lib/navigation.js";import{I18nProvider}from"../../../components/i18n-provider.js";import{SSOButtons,SSOButtonsSkeleton}from"../sso/buttons/sso-buttons.js";import{FormSignUp}from"./form/form.js";import{WrapperSignUp}from"./wrapper.js";export const SignUpView=async()=>{const[t,tGlobal,{isEmail,captcha}]=await Promise.all([getTranslations("core.auth.sign_up"),getTranslations("core.global"),getMiddlewareApi()]);return _jsx(I18nProvider,{namespaces:"core.auth.sign_up",children:_jsx("div",{className:"mx-auto flex min-h-[calc(100vh-4rem)] max-w-md flex-col justify-center px-4 py-16",children:_jsx(WrapperSignUp,{children:_jsxs(Card,{className:"bg-muted gap-0 p-0",children:[_jsxs("div",{className:"bg-card rounded-xl p-6",children:[_jsxs("div",{className:"mb-10 space-y-2 text-center",children:[_jsx("h1",{className:"text-2xl leading-none font-semibold tracking-tight",children:tGlobal("register")}),_jsx(CardDescription,{children:t("desc")})]}),_jsx(FormSignUp,{captcha:captcha,isEmail:isEmail}),_jsx(React.Suspense,{fallback:_jsx(SSOButtonsSkeleton,{}),children:_jsx(SSOButtons,{})})]}),_jsx("div",{className:"text-accent-foreground p-6 text-center text-sm",children:t.rich("already_have_account",{link:text=>_jsx(Link,{className:"text-primary font-semibold",href:"/login",children:text})})})]})})})})};
|