@yimingliao/cms 0.0.88 → 0.0.90
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/{create-verify-action-DBwWOXPO.d.ts → action-context-yvi5OrMJ.d.ts} +2 -6
- package/dist/{chunk-OQGJBZXQ.js → chunk-BVWT2DIB.js} +32 -2
- package/dist/client/index.d.ts +147 -5
- package/dist/client/index.js +445 -9
- package/dist/client/shadcn/index.js +1 -1
- package/dist/server/index.d.ts +4 -71
- package/dist/server/index.js +1 -308
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TocItem, i as AdminRole, y as SingleItem, B as BaseTranslation, e as Admin, g as AdminFull, j as AdminSafe, D as DeviceInfo, h as AdminRefreshToken, p as File, b as FileFull, r as FileType, a as Folder, F as FolderFull, M as MultiItems, m as ExternalLink, o as Faq, t as Post, w as PostType, u as PostListCard, v as PostTranslation, P as PostFull, l as Alternate, S as SuccessResult, R as Result } from './types-BGsFazJr.js';
|
|
2
1
|
import { S as StorageService } from './types-J25u1G6t.js';
|
|
2
|
+
import { T as TocItem, i as AdminRole, y as SingleItem, B as BaseTranslation, e as Admin, g as AdminFull, j as AdminSafe, D as DeviceInfo, h as AdminRefreshToken, p as File, b as FileFull, r as FileType, a as Folder, F as FolderFull, M as MultiItems, m as ExternalLink, o as Faq, t as Post, w as PostType, u as PostListCard, v as PostTranslation, P as PostFull, l as Alternate, S as SuccessResult, R as Result } from './types-BGsFazJr.js';
|
|
3
3
|
import jwt from 'jsonwebtoken';
|
|
4
4
|
import { BinaryLike } from 'node:crypto';
|
|
5
5
|
import { cookies } from 'next/headers';
|
|
@@ -855,8 +855,4 @@ interface ActionContext {
|
|
|
855
855
|
};
|
|
856
856
|
}
|
|
857
857
|
|
|
858
|
-
|
|
859
|
-
admin: AdminFull;
|
|
860
|
-
}>>;
|
|
861
|
-
|
|
862
|
-
export { type ActionContext as A, createRenderEmailTemplate as B, createSendEmail as C, createSeoMetadataCommandRepository as D, createUnique as E, createVerifyAccessToken as F, createVerifyRefreshToken as G, normalizeCacheKey as H, type RawCacheKey as R, createZod as a, createSchemas as b, createVerifyAction as c, createTocItemSchema as d, createAdminCommandRepository as e, createAdminQueryRepository as f, createAdminRefreshTokenCommandRepository as g, createAdminRefreshTokenQueryRepository as h, createArgon2Service as i, createAuthMiddleware as j, createAuthUseCases as k, createCacheResult as l, createCookieService as m, createCryptoService as n, createEmailVerificationEmail as o, createExecuteAction as p, createExist as q, createFileCommandRepository as r, createFileQueryRepository as s, createFolderCommandRepository as t, createFolderQueryRepository as u, createForgotPasswordEmail as v, createIpRateLimiter as w, createJwtService as x, createPostCommandRepository as y, createPostQueryRepository as z };
|
|
858
|
+
export { type ActionContext as A, createSendEmail as B, createSeoMetadataCommandRepository as C, createUnique as D, createVerifyAccessToken as E, createVerifyRefreshToken as F, normalizeCacheKey as G, type RawCacheKey as R, createZod as a, createTocItemSchema as b, createSchemas as c, createAdminCommandRepository as d, createAdminQueryRepository as e, createAdminRefreshTokenCommandRepository as f, createAdminRefreshTokenQueryRepository as g, createArgon2Service as h, createAuthMiddleware as i, createAuthUseCases as j, createCacheResult as k, createCookieService as l, createCryptoService as m, createEmailVerificationEmail as n, createExecuteAction as o, createExist as p, createFileCommandRepository as q, createFileQueryRepository as r, createFolderCommandRepository as s, createFolderQueryRepository as t, createForgotPasswordEmail as u, createIpRateLimiter as v, createJwtService as w, createPostCommandRepository as x, createPostQueryRepository as y, createRenderEmailTemplate as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
import { twMerge } from 'tailwind-merge';
|
|
3
|
-
import { useState, useEffect } from 'react';
|
|
3
|
+
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
4
4
|
import { UAParser } from 'ua-parser-js';
|
|
5
5
|
import { Slot } from '@radix-ui/react-slot';
|
|
6
6
|
import { cva } from 'class-variance-authority';
|
|
@@ -12,6 +12,36 @@ import * as LabelPrimitive from '@radix-ui/react-label';
|
|
|
12
12
|
var cn = (...inputs) => {
|
|
13
13
|
return twMerge(clsx(inputs));
|
|
14
14
|
};
|
|
15
|
+
var useCountdown = (initialTime) => {
|
|
16
|
+
const [timeLeft, setTimeLeft] = useState(initialTime);
|
|
17
|
+
const [isCounting, setIsCounting] = useState(false);
|
|
18
|
+
const intervalRef = useRef(null);
|
|
19
|
+
const startCountdown = useCallback(() => {
|
|
20
|
+
setTimeLeft(initialTime);
|
|
21
|
+
setIsCounting(true);
|
|
22
|
+
}, [initialTime]);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!isCounting) return;
|
|
25
|
+
intervalRef.current = setInterval(() => {
|
|
26
|
+
setTimeLeft((prev) => {
|
|
27
|
+
if (prev <= 1) {
|
|
28
|
+
clearInterval(intervalRef.current);
|
|
29
|
+
intervalRef.current = null;
|
|
30
|
+
setIsCounting(false);
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
return prev - 1;
|
|
34
|
+
});
|
|
35
|
+
}, 1e3);
|
|
36
|
+
return () => {
|
|
37
|
+
if (intervalRef.current) {
|
|
38
|
+
clearInterval(intervalRef.current);
|
|
39
|
+
intervalRef.current = null;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}, [isCounting]);
|
|
43
|
+
return { timeLeft, isCounting, startCountdown };
|
|
44
|
+
};
|
|
15
45
|
function useDeviceInfo() {
|
|
16
46
|
const [deviceInfo, setDeviceInfo] = useState(null);
|
|
17
47
|
useEffect(() => {
|
|
@@ -355,4 +385,4 @@ function Label({ className, ...props }) {
|
|
|
355
385
|
);
|
|
356
386
|
}
|
|
357
387
|
|
|
358
|
-
export { Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Spinner, Textarea, cn, useDeviceInfo };
|
|
388
|
+
export { Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Spinner, Textarea, cn, useCountdown, useDeviceInfo };
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { z as Translation, R as Result, S as SuccessResult, d as ErrorResult, g as AdminFull, D as DeviceInfo } from '../types-BGsFazJr.js';
|
|
1
|
+
import { z as Translation, R as Result, S as SuccessResult, d as ErrorResult, g as AdminFull, D as DeviceInfo, j as AdminSafe } from '../types-BGsFazJr.js';
|
|
2
2
|
import { Logger } from 'logry';
|
|
3
3
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
4
4
|
import { QueryClient, UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';
|
|
5
5
|
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
|
-
import { c as
|
|
7
|
+
import { c as createSchemas, A as ActionContext } from '../action-context-yvi5OrMJ.js';
|
|
8
8
|
import * as React$1 from 'react';
|
|
9
9
|
import { ComponentProps, ReactNode, HTMLAttributes } from 'react';
|
|
10
10
|
import { L as LabelProps, B as ButtonProps$1 } from '../label-BF4qxS03.js';
|
|
11
11
|
import { LucideIcon } from 'lucide-react';
|
|
12
|
+
import * as zod from 'zod';
|
|
13
|
+
import zod__default from 'zod';
|
|
14
|
+
import * as zod_v4_core from 'zod/v4/core';
|
|
12
15
|
import { ClassValue } from 'clsx';
|
|
13
16
|
import '../types-J25u1G6t.js';
|
|
14
17
|
import '../types-0oS1A2K5.js';
|
|
@@ -16,11 +19,9 @@ import 'jsonwebtoken';
|
|
|
16
19
|
import 'node:crypto';
|
|
17
20
|
import 'next/headers';
|
|
18
21
|
import '@prisma/client';
|
|
19
|
-
import 'zod';
|
|
20
22
|
import 'nodemailer';
|
|
21
23
|
import 'intor';
|
|
22
24
|
import 'keyv';
|
|
23
|
-
import 'zod/v4/core';
|
|
24
25
|
import 'class-variance-authority/types';
|
|
25
26
|
import 'class-variance-authority';
|
|
26
27
|
import '@radix-ui/react-label';
|
|
@@ -343,6 +344,75 @@ declare function AdminProvider({ children }: {
|
|
|
343
344
|
}): react_jsx_runtime.JSX.Element;
|
|
344
345
|
declare function useAdmin(): AdminContextValue;
|
|
345
346
|
|
|
347
|
+
declare const signInValidator: (schemas: ReturnType<typeof createSchemas>) => zod__default.ZodObject<{
|
|
348
|
+
email: zod__default.ZodEmail;
|
|
349
|
+
password: zod__default.ZodString;
|
|
350
|
+
}, zod__default.core.$strip>;
|
|
351
|
+
|
|
352
|
+
type SignInFormData = zod__default.infer<ReturnType<typeof signInValidator>>;
|
|
353
|
+
declare function createSignInAction(ctx: ActionContext): ({ formData, deviceInfo, }: {
|
|
354
|
+
formData: SignInFormData;
|
|
355
|
+
deviceInfo: DeviceInfo;
|
|
356
|
+
}) => Promise<Result<{
|
|
357
|
+
admin: AdminFull;
|
|
358
|
+
}>>;
|
|
359
|
+
|
|
360
|
+
declare function createVerifyAction(ctx: ActionContext): () => Promise<Result<{
|
|
361
|
+
admin: AdminFull;
|
|
362
|
+
}>>;
|
|
363
|
+
|
|
364
|
+
declare const changePasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
|
|
365
|
+
password: zod.ZodString;
|
|
366
|
+
newPassword: zod.ZodString;
|
|
367
|
+
newPasswordConfirm: zod.ZodString;
|
|
368
|
+
}, zod_v4_core.$strip>;
|
|
369
|
+
|
|
370
|
+
type ChangePasswordFormData = zod__default.infer<ReturnType<typeof changePasswordValidator>>;
|
|
371
|
+
declare function createChangePasswordAction(ctx: ActionContext): ({ formData, }: {
|
|
372
|
+
formData: ChangePasswordFormData;
|
|
373
|
+
}) => Promise<Result<void>>;
|
|
374
|
+
|
|
375
|
+
declare const verifyEmailValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
|
|
376
|
+
email: zod.ZodEmail;
|
|
377
|
+
emailVerificationToken: zod.ZodString;
|
|
378
|
+
}, zod_v4_core.$strip>;
|
|
379
|
+
|
|
380
|
+
type VerifyEmailFormData = zod__default.infer<ReturnType<typeof verifyEmailValidator>>;
|
|
381
|
+
declare function createVerifyEmailAction(ctx: ActionContext): ({ formData, }: {
|
|
382
|
+
formData: VerifyEmailFormData;
|
|
383
|
+
}) => Promise<Result<{
|
|
384
|
+
admin: AdminSafe;
|
|
385
|
+
}>>;
|
|
386
|
+
|
|
387
|
+
declare const emailUnverifiedValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
|
|
388
|
+
email: zod.ZodEmail;
|
|
389
|
+
}, zod_v4_core.$strip>;
|
|
390
|
+
|
|
391
|
+
type EmailUnverifiedFormData = zod__default.infer<ReturnType<typeof emailUnverifiedValidator>>;
|
|
392
|
+
declare function createEmailUnverifiedAction(ctx: ActionContext): ({ formData, }: {
|
|
393
|
+
formData: EmailUnverifiedFormData;
|
|
394
|
+
}) => Promise<Result<void>>;
|
|
395
|
+
|
|
396
|
+
declare const forgetPasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
|
|
397
|
+
email: zod.ZodEmail;
|
|
398
|
+
}, zod_v4_core.$strip>;
|
|
399
|
+
|
|
400
|
+
type ForgotPasswordFormData = zod__default.infer<ReturnType<typeof forgetPasswordValidator>>;
|
|
401
|
+
declare function createForgotPasswordAction(ctx: ActionContext): ({ formData, }: {
|
|
402
|
+
formData: ForgotPasswordFormData;
|
|
403
|
+
}) => Promise<Result<void>>;
|
|
404
|
+
|
|
405
|
+
declare const resetPasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
|
|
406
|
+
passwordResetToken: zod.ZodString;
|
|
407
|
+
newPassword: zod.ZodString;
|
|
408
|
+
newPasswordConfirm: zod.ZodString;
|
|
409
|
+
}, zod_v4_core.$strip>;
|
|
410
|
+
|
|
411
|
+
type ResetPasswordFormData = zod__default.infer<ReturnType<typeof resetPasswordValidator>>;
|
|
412
|
+
declare function createResetPasswordAction(ctx: ActionContext): ({ formData, }: {
|
|
413
|
+
formData: ResetPasswordFormData;
|
|
414
|
+
}) => Promise<Result<void>>;
|
|
415
|
+
|
|
346
416
|
declare function createAdminInitializer({ useAdmin, useQuery, verifyAction, }: {
|
|
347
417
|
useAdmin: () => AdminContextValue;
|
|
348
418
|
useQuery: ReturnType<typeof createUseQuery>;
|
|
@@ -380,8 +450,80 @@ declare function Input<T>({ fieldName, setFormData, isLoading, isDisabled, isErr
|
|
|
380
450
|
|
|
381
451
|
declare function PasswordInput<T>({ ...props }: InputProps<T>): react_jsx_runtime.JSX.Element;
|
|
382
452
|
|
|
453
|
+
/**
|
|
454
|
+
* [Auth] sign-in
|
|
455
|
+
*
|
|
456
|
+
* http://localhost:3000/cms/sign-in
|
|
457
|
+
*
|
|
458
|
+
* src/app/cms/(auth)/sign-in/page.tsx
|
|
459
|
+
*/
|
|
460
|
+
declare function createSignInPage({ useCommand, signInAction, }: {
|
|
461
|
+
useCommand: ReturnType<typeof createUseCommand>;
|
|
462
|
+
signInAction: ReturnType<typeof createSignInAction>;
|
|
463
|
+
}): () => react_jsx_runtime.JSX.Element;
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* [Auth] verify email
|
|
467
|
+
*
|
|
468
|
+
* http://localhost:3000/cms/verify-email
|
|
469
|
+
*
|
|
470
|
+
* src/app/cms/(auth)/verify-email/page.tsx
|
|
471
|
+
*/
|
|
472
|
+
declare function createVerifyEmailPage({ useCommand, verifyEmailAction, }: {
|
|
473
|
+
useCommand: ReturnType<typeof createUseCommand>;
|
|
474
|
+
verifyEmailAction: ReturnType<typeof createVerifyEmailAction>;
|
|
475
|
+
}): () => react_jsx_runtime.JSX.Element;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* [Auth] email unverified
|
|
479
|
+
*
|
|
480
|
+
* http://localhost:3000/cms/email-unverified
|
|
481
|
+
*
|
|
482
|
+
* src/app/cms/(auth)/email-unverified/page.tsx
|
|
483
|
+
*/
|
|
484
|
+
declare function createEmailUnverifiedPage({ useCommand, emailUnverifiedAction, }: {
|
|
485
|
+
useCommand: ReturnType<typeof createUseCommand>;
|
|
486
|
+
emailUnverifiedAction: ReturnType<typeof createEmailUnverifiedAction>;
|
|
487
|
+
}): () => react_jsx_runtime.JSX.Element;
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* [Auth] forgot-password
|
|
491
|
+
*
|
|
492
|
+
* http://localhost:3000/cms/forgot-password
|
|
493
|
+
*
|
|
494
|
+
* src/app/cms/(auth)/forgot-password/page.tsx
|
|
495
|
+
*/
|
|
496
|
+
declare function createForgotPasswordPage({ useCommand, forgotPasswordAction, }: {
|
|
497
|
+
useCommand: ReturnType<typeof createUseCommand>;
|
|
498
|
+
forgotPasswordAction: ReturnType<typeof createForgotPasswordAction>;
|
|
499
|
+
}): () => react_jsx_runtime.JSX.Element;
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* [Auth] reset-password
|
|
503
|
+
*
|
|
504
|
+
* http://localhost:3000/cms/reset-password
|
|
505
|
+
*
|
|
506
|
+
* src/app/cms/(auth)/reset-password/page.tsx
|
|
507
|
+
*/
|
|
508
|
+
declare function createResetPasswordPage({ useCommand, resetPasswordAction, }: {
|
|
509
|
+
useCommand: ReturnType<typeof createUseCommand>;
|
|
510
|
+
resetPasswordAction: ReturnType<typeof createResetPasswordAction>;
|
|
511
|
+
}): () => react_jsx_runtime.JSX.Element;
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* [Auth] change-password
|
|
515
|
+
*
|
|
516
|
+
* http://localhost:3000/cms/dashboard/change-password
|
|
517
|
+
*
|
|
518
|
+
* src/app/cms/dashboard/(auth)/change-password/page.tsx
|
|
519
|
+
*/
|
|
520
|
+
declare function createChangePasswordPage({ useCommand, changePasswordAction, }: {
|
|
521
|
+
useCommand: ReturnType<typeof createUseCommand>;
|
|
522
|
+
changePasswordAction: ReturnType<typeof createChangePasswordAction>;
|
|
523
|
+
}): () => react_jsx_runtime.JSX.Element;
|
|
524
|
+
|
|
383
525
|
declare const cn: (...inputs: ClassValue[]) => string;
|
|
384
526
|
|
|
385
527
|
declare function useDeviceInfo(): DeviceInfo | null;
|
|
386
528
|
|
|
387
|
-
export { AdminProvider, Button, type ButtonProps, Field, FieldBody, Form, Input, type InputProps, PasswordInput, type ShowToastOption, cn, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin, useDeviceInfo };
|
|
529
|
+
export { AdminProvider, Button, type ButtonProps, Field, FieldBody, Form, Input, type InputProps, PasswordInput, type ShowToastOption, cn, createAdminInitializer, createChangePasswordPage, createEmailUnverifiedPage, createForgotPasswordPage, createRequestInterceptor, createResetPasswordPage, createResponseInterceptor, createSignInPage, createSmartFetch, createUseCommand, createUseQuery, createVerifyEmailPage, handleToast, useAdmin, useDeviceInfo };
|
package/dist/client/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { cn, Label, Spinner, Button, InputGroup, InputGroupAddon, InputGroupInput, InputGroupButton } from '../chunk-
|
|
2
|
-
export { cn, useDeviceInfo } from '../chunk-
|
|
1
|
+
import { cn, Label, Spinner, Button, InputGroup, InputGroupAddon, InputGroupInput, InputGroupButton, useDeviceInfo, Card, CardHeader, CardTitle, CardContent, useCountdown, CardDescription } from '../chunk-BVWT2DIB.js';
|
|
2
|
+
export { cn, useDeviceInfo } from '../chunk-BVWT2DIB.js';
|
|
3
3
|
import { ensureArray } from '../chunk-OAENV763.js';
|
|
4
4
|
import { toast } from 'sonner';
|
|
5
5
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
6
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import { Asterisk, Eye, EyeOff } from 'lucide-react';
|
|
7
|
+
import { createContext, useState, useContext, useEffect, createElement } from 'react';
|
|
8
|
+
import { Asterisk, Eye, EyeOff, Mail } from 'lucide-react';
|
|
10
9
|
import { useTranslator } from 'intor/react';
|
|
11
|
-
import { useRouter } from 'next/navigation';
|
|
10
|
+
import { useRouter, useSearchParams } from 'next/navigation';
|
|
11
|
+
import Link from 'next/link';
|
|
12
12
|
|
|
13
13
|
// src/client/infrastructure/fetch/smart-fetch.ts
|
|
14
14
|
function createSmartFetch({
|
|
@@ -265,7 +265,7 @@ function Field({
|
|
|
265
265
|
/* @__PURE__ */ jsxs(Label, { className: "flex gap-1 truncate", ...props, children: [
|
|
266
266
|
label,
|
|
267
267
|
isRequired && /* @__PURE__ */ jsx(Asterisk, { className: "text-destructive size-3" }),
|
|
268
|
-
hint && /* @__PURE__ */ jsx("span", { className: "ml-2 text-xs
|
|
268
|
+
hint && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground ml-2 text-xs", children: hint })
|
|
269
269
|
] }),
|
|
270
270
|
/* @__PURE__ */ jsx("span", { children: labelChildren })
|
|
271
271
|
] }),
|
|
@@ -355,7 +355,7 @@ function Button2({
|
|
|
355
355
|
onClick: props.onClick ?? handleClick,
|
|
356
356
|
...props,
|
|
357
357
|
children: isLoading ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
358
|
-
icon &&
|
|
358
|
+
icon && createElement(icon),
|
|
359
359
|
children
|
|
360
360
|
] })
|
|
361
361
|
}
|
|
@@ -403,4 +403,440 @@ function PasswordInput({ ...props }) {
|
|
|
403
403
|
) }) });
|
|
404
404
|
}
|
|
405
405
|
|
|
406
|
-
|
|
406
|
+
// src/constants/keys/auth.ts
|
|
407
|
+
var AUTH_KEYS = {
|
|
408
|
+
signIn: { key: "sign-in" },
|
|
409
|
+
forgotPassword: { key: "forgot-password" }};
|
|
410
|
+
|
|
411
|
+
// src/constants/keys/main.ts
|
|
412
|
+
var MAIN_KEYS = {
|
|
413
|
+
dashboard: { key: "dashboard" },
|
|
414
|
+
cmsSettings: { key: "cms-settings" }};
|
|
415
|
+
|
|
416
|
+
// src/constants/keys/resources.ts
|
|
417
|
+
var RESOURCES_KEYS = {
|
|
418
|
+
admin: { key: "admin" }};
|
|
419
|
+
|
|
420
|
+
// src/constants/keys/index.ts
|
|
421
|
+
var KEYS = {
|
|
422
|
+
main: MAIN_KEYS,
|
|
423
|
+
auth: AUTH_KEYS,
|
|
424
|
+
resources: RESOURCES_KEYS};
|
|
425
|
+
|
|
426
|
+
// src/constants/paths/cms-path.ts
|
|
427
|
+
var CMS_PATH = "/cms";
|
|
428
|
+
|
|
429
|
+
// src/constants/paths/main.ts
|
|
430
|
+
var MAIN_PATHS = {
|
|
431
|
+
dashboard: {
|
|
432
|
+
path: `${CMS_PATH}/${KEYS.main.dashboard.key}`
|
|
433
|
+
},
|
|
434
|
+
cmsSettings: {
|
|
435
|
+
path: `${CMS_PATH}/${KEYS.main.dashboard.key}/${KEYS.main.cmsSettings.key}`
|
|
436
|
+
}};
|
|
437
|
+
|
|
438
|
+
// src/constants/paths/auth.ts
|
|
439
|
+
var AUTH_PATHS = {
|
|
440
|
+
signIn: {
|
|
441
|
+
path: `${CMS_PATH}/${KEYS.auth.signIn.key}`
|
|
442
|
+
},
|
|
443
|
+
forgotPassword: {
|
|
444
|
+
path: `${CMS_PATH}/${KEYS.auth.forgotPassword.key}`
|
|
445
|
+
}};
|
|
446
|
+
|
|
447
|
+
// src/constants/paths/resources.ts
|
|
448
|
+
var RESOURCES_PATHS = {
|
|
449
|
+
admin: {
|
|
450
|
+
path: `${MAIN_PATHS.cmsSettings.path}/${KEYS.resources.admin.key}`
|
|
451
|
+
}};
|
|
452
|
+
|
|
453
|
+
// src/constants/paths/index.ts
|
|
454
|
+
var PATHS = {
|
|
455
|
+
main: MAIN_PATHS,
|
|
456
|
+
auth: AUTH_PATHS,
|
|
457
|
+
resources: RESOURCES_PATHS
|
|
458
|
+
};
|
|
459
|
+
function createSignInPage({
|
|
460
|
+
useCommand,
|
|
461
|
+
signInAction
|
|
462
|
+
}) {
|
|
463
|
+
return function SignInPage() {
|
|
464
|
+
const { t } = useTranslator();
|
|
465
|
+
const { setAdmin } = useAdmin();
|
|
466
|
+
const deviceInfo = useDeviceInfo();
|
|
467
|
+
const [formData, setFormData] = useState({
|
|
468
|
+
email: "",
|
|
469
|
+
password: ""
|
|
470
|
+
});
|
|
471
|
+
const { execute, isRedirecting, errors } = useCommand(
|
|
472
|
+
() => signInAction({
|
|
473
|
+
formData,
|
|
474
|
+
deviceInfo: deviceInfo ?? {}
|
|
475
|
+
}),
|
|
476
|
+
{ onSuccess: (data) => setAdmin(data?.admin || null) }
|
|
477
|
+
);
|
|
478
|
+
return /* @__PURE__ */ jsx(Form, { className: "mx-auto mt-20 w-96", onSubmit: () => void execute(), children: /* @__PURE__ */ jsxs(Card, { children: [
|
|
479
|
+
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.sign-in.text") }) }),
|
|
480
|
+
/* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
|
|
481
|
+
/* @__PURE__ */ jsx(Field, { htmlFor: "email", label: t("auth.sign-in.email.text"), children: /* @__PURE__ */ jsx(
|
|
482
|
+
Input,
|
|
483
|
+
{
|
|
484
|
+
id: "email",
|
|
485
|
+
type: "email",
|
|
486
|
+
placeholder: t("auth.sign-in.email.placeholder.text"),
|
|
487
|
+
autoComplete: "email",
|
|
488
|
+
fieldName: "email",
|
|
489
|
+
value: formData.email,
|
|
490
|
+
setFormData,
|
|
491
|
+
isDisabled: isRedirecting,
|
|
492
|
+
isError: errors.includes("email")
|
|
493
|
+
}
|
|
494
|
+
) }),
|
|
495
|
+
/* @__PURE__ */ jsx(Field, { htmlFor: "password", label: t("auth.sign-in.password.text"), children: /* @__PURE__ */ jsx(
|
|
496
|
+
PasswordInput,
|
|
497
|
+
{
|
|
498
|
+
id: "password",
|
|
499
|
+
placeholder: t("auth.sign-in.password.placeholder.text"),
|
|
500
|
+
fieldName: "password",
|
|
501
|
+
value: formData.password,
|
|
502
|
+
setFormData,
|
|
503
|
+
isDisabled: isRedirecting,
|
|
504
|
+
isError: errors.includes("password")
|
|
505
|
+
}
|
|
506
|
+
) }),
|
|
507
|
+
/* @__PURE__ */ jsx(
|
|
508
|
+
Button2,
|
|
509
|
+
{
|
|
510
|
+
size: "xs",
|
|
511
|
+
variant: "link",
|
|
512
|
+
className: "w-fit",
|
|
513
|
+
isDisabled: isRedirecting,
|
|
514
|
+
children: /* @__PURE__ */ jsx(Link, { href: PATHS.auth.forgotPassword.path, children: t("auth.sign-in.anchor.text") })
|
|
515
|
+
}
|
|
516
|
+
),
|
|
517
|
+
/* @__PURE__ */ jsx(Button2, { type: "submit", isLoading: isRedirecting, children: t("auth.sign-in.button.text") })
|
|
518
|
+
] })
|
|
519
|
+
] }) });
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
function createVerifyEmailPage({
|
|
523
|
+
useCommand,
|
|
524
|
+
verifyEmailAction
|
|
525
|
+
}) {
|
|
526
|
+
return function VerifyEmailPage() {
|
|
527
|
+
const router = useRouter();
|
|
528
|
+
const searchParams = useSearchParams();
|
|
529
|
+
const email = searchParams.get("email") ?? "";
|
|
530
|
+
const emailVerificationToken = searchParams.get("emailVerificationToken") ?? "";
|
|
531
|
+
const { execute } = useCommand(
|
|
532
|
+
() => verifyEmailAction({ formData: { email, emailVerificationToken } }),
|
|
533
|
+
{
|
|
534
|
+
onSuccess: (data) => router.push(`${PATHS.resources.admin.path}/${data?.admin.id}`),
|
|
535
|
+
onError: () => router.push(PATHS.auth.signIn.path)
|
|
536
|
+
}
|
|
537
|
+
);
|
|
538
|
+
useEffect(() => {
|
|
539
|
+
void (async () => {
|
|
540
|
+
if (email && emailVerificationToken) {
|
|
541
|
+
await execute();
|
|
542
|
+
} else {
|
|
543
|
+
router.push(PATHS.auth.signIn.path);
|
|
544
|
+
}
|
|
545
|
+
})();
|
|
546
|
+
}, [email, emailVerificationToken]);
|
|
547
|
+
return /* @__PURE__ */ jsx("div", { className: "flex-center relative flex-1 flex-col", children: /* @__PURE__ */ jsx(Spinner, { className: "size-10" }) });
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
function createEmailUnverifiedPage({
|
|
551
|
+
useCommand,
|
|
552
|
+
emailUnverifiedAction
|
|
553
|
+
}) {
|
|
554
|
+
return function EmailUnverifiedPage() {
|
|
555
|
+
const { t } = useTranslator();
|
|
556
|
+
const router = useRouter();
|
|
557
|
+
const { admin, isLoading } = useAdmin();
|
|
558
|
+
const { timeLeft, isCounting, startCountdown } = useCountdown(30);
|
|
559
|
+
useEffect(() => {
|
|
560
|
+
if (!admin && !isLoading) {
|
|
561
|
+
router.replace(PATHS.auth.signIn.path);
|
|
562
|
+
}
|
|
563
|
+
if (admin?.emailVerifiedAt) {
|
|
564
|
+
router.replace(PATHS.main.dashboard.path);
|
|
565
|
+
}
|
|
566
|
+
}, [admin, isLoading, router]);
|
|
567
|
+
const { execute, isPending } = useCommand(
|
|
568
|
+
() => emailUnverifiedAction({ formData: { email: admin?.email ?? "" } }),
|
|
569
|
+
{ onSuccess: () => startCountdown() }
|
|
570
|
+
);
|
|
571
|
+
const buttonText = !isCounting ? t("auth.email-unverified.button.send-email.text") : /* @__PURE__ */ jsxs("span", { children: [
|
|
572
|
+
t("auth.email-unverified.button.please-wait.text"),
|
|
573
|
+
/* @__PURE__ */ jsx("span", { className: "ml-1 inline-block w-5 text-end", children: timeLeft }),
|
|
574
|
+
"\xA0",
|
|
575
|
+
t("auth.email-unverified.button.second.text"),
|
|
576
|
+
"\xA0",
|
|
577
|
+
t("auth.email-unverified.button.send-again.text")
|
|
578
|
+
] });
|
|
579
|
+
return /* @__PURE__ */ jsx(Form, { className: "mx-auto mt-20 w-96", onSubmit: () => void execute(), children: /* @__PURE__ */ jsxs(Card, { children: [
|
|
580
|
+
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.email-unverified.text") }) }),
|
|
581
|
+
/* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
|
|
582
|
+
/* @__PURE__ */ jsxs(InputGroup, { children: [
|
|
583
|
+
/* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(Label, { htmlFor: "email", className: "text-foreground", children: /* @__PURE__ */ jsx(Mail, { className: "size-4" }) }) }),
|
|
584
|
+
isLoading ? /* @__PURE__ */ jsx("div", { className: "px-2", children: /* @__PURE__ */ jsx(Spinner, {}) }) : /* @__PURE__ */ jsx(
|
|
585
|
+
InputGroupInput,
|
|
586
|
+
{
|
|
587
|
+
id: "email",
|
|
588
|
+
placeholder: "shadcn@vercel.com",
|
|
589
|
+
disabled: true,
|
|
590
|
+
value: admin?.email
|
|
591
|
+
}
|
|
592
|
+
)
|
|
593
|
+
] }),
|
|
594
|
+
/* @__PURE__ */ jsx(CardDescription, { children: /* @__PURE__ */ jsx("p", { className: "text-sm whitespace-pre-line", children: t("auth.email-unverified.notice.text") }) }),
|
|
595
|
+
/* @__PURE__ */ jsx(
|
|
596
|
+
Button2,
|
|
597
|
+
{
|
|
598
|
+
type: "submit",
|
|
599
|
+
isLoading: isLoading || isPending,
|
|
600
|
+
isDisabled: isCounting,
|
|
601
|
+
children: buttonText
|
|
602
|
+
}
|
|
603
|
+
)
|
|
604
|
+
] })
|
|
605
|
+
] }) });
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
function createForgotPasswordPage({
|
|
609
|
+
useCommand,
|
|
610
|
+
forgotPasswordAction
|
|
611
|
+
}) {
|
|
612
|
+
return function ForgotPasswordPage() {
|
|
613
|
+
const { t } = useTranslator();
|
|
614
|
+
const { timeLeft, isCounting, startCountdown } = useCountdown(30);
|
|
615
|
+
const [formData, setFormData] = useState({
|
|
616
|
+
email: ""
|
|
617
|
+
});
|
|
618
|
+
const { execute, isPending, errors } = useCommand(
|
|
619
|
+
() => forgotPasswordAction({ formData: { email: formData.email } }),
|
|
620
|
+
{ onSuccess: () => startCountdown() }
|
|
621
|
+
);
|
|
622
|
+
const buttonText = !isCounting ? t("auth.forgot-password.button.send-email.text") : /* @__PURE__ */ jsxs("span", { children: [
|
|
623
|
+
t("auth.forgot-password.button.please-wait.text"),
|
|
624
|
+
/* @__PURE__ */ jsx("span", { className: "ml-1 inline-block w-5 text-end", children: timeLeft }),
|
|
625
|
+
"\xA0",
|
|
626
|
+
t("auth.forgot-password.button.second.text"),
|
|
627
|
+
"\xA0",
|
|
628
|
+
t("auth.forgot-password.button.send-again.text")
|
|
629
|
+
] });
|
|
630
|
+
return /* @__PURE__ */ jsx(Form, { className: "mx-auto mt-20 w-96", onSubmit: () => void execute(), children: /* @__PURE__ */ jsxs(Card, { children: [
|
|
631
|
+
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.forgot-password.text") }) }),
|
|
632
|
+
/* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
|
|
633
|
+
/* @__PURE__ */ jsx(Field, { htmlFor: "email", label: t("auth.forgot-password.email.text"), children: /* @__PURE__ */ jsx(
|
|
634
|
+
Input,
|
|
635
|
+
{
|
|
636
|
+
id: "email",
|
|
637
|
+
placeholder: t("auth.forgot-password.email.placeholder.text"),
|
|
638
|
+
autoComplete: "email",
|
|
639
|
+
fieldName: "email",
|
|
640
|
+
value: formData.email,
|
|
641
|
+
setFormData,
|
|
642
|
+
isDisabled: isPending || isCounting,
|
|
643
|
+
isError: errors.includes("email")
|
|
644
|
+
}
|
|
645
|
+
) }),
|
|
646
|
+
/* @__PURE__ */ jsx(
|
|
647
|
+
Button2,
|
|
648
|
+
{
|
|
649
|
+
size: "xs",
|
|
650
|
+
variant: "link",
|
|
651
|
+
className: "w-fit",
|
|
652
|
+
isDisabled: isPending,
|
|
653
|
+
children: /* @__PURE__ */ jsx(Link, { href: PATHS.auth.signIn.path, children: t("auth.forgot-password.anchor.text") })
|
|
654
|
+
}
|
|
655
|
+
),
|
|
656
|
+
/* @__PURE__ */ jsx(Button2, { type: "submit", isLoading: isPending, isDisabled: isCounting, children: buttonText })
|
|
657
|
+
] })
|
|
658
|
+
] }) });
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
function createResetPasswordPage({
|
|
662
|
+
useCommand,
|
|
663
|
+
resetPasswordAction
|
|
664
|
+
}) {
|
|
665
|
+
return function ResetPasswordPage() {
|
|
666
|
+
const { t } = useTranslator();
|
|
667
|
+
const router = useRouter();
|
|
668
|
+
const passwordResetToken = useSearchParams().get("passwordResetToken") ?? "";
|
|
669
|
+
const [formData, setFormData] = useState({
|
|
670
|
+
newPassword: "",
|
|
671
|
+
newPasswordConfirm: ""
|
|
672
|
+
});
|
|
673
|
+
const { execute, isRedirecting, errors } = useCommand(
|
|
674
|
+
() => resetPasswordAction({ formData: { passwordResetToken, ...formData } }),
|
|
675
|
+
{ onSuccess: () => router.push(PATHS.auth.signIn.path) }
|
|
676
|
+
);
|
|
677
|
+
return /* @__PURE__ */ jsx(Form, { className: "mx-auto mt-20 w-96", onSubmit: () => void execute(), children: /* @__PURE__ */ jsxs(Card, { children: [
|
|
678
|
+
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.reset-password.text") }) }),
|
|
679
|
+
/* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
|
|
680
|
+
/* @__PURE__ */ jsx(
|
|
681
|
+
Field,
|
|
682
|
+
{
|
|
683
|
+
htmlFor: "newPassword",
|
|
684
|
+
label: t("auth.reset-password.new-password.text"),
|
|
685
|
+
children: /* @__PURE__ */ jsx(
|
|
686
|
+
PasswordInput,
|
|
687
|
+
{
|
|
688
|
+
id: "newPassword",
|
|
689
|
+
placeholder: t(
|
|
690
|
+
"auth.reset-password.new-password.placeholder.text"
|
|
691
|
+
),
|
|
692
|
+
fieldName: "newPassword",
|
|
693
|
+
value: formData.newPassword,
|
|
694
|
+
setFormData,
|
|
695
|
+
isDisabled: isRedirecting,
|
|
696
|
+
isError: errors.includes("newPassword")
|
|
697
|
+
}
|
|
698
|
+
)
|
|
699
|
+
}
|
|
700
|
+
),
|
|
701
|
+
/* @__PURE__ */ jsx(
|
|
702
|
+
Field,
|
|
703
|
+
{
|
|
704
|
+
htmlFor: "newPasswordConfirm",
|
|
705
|
+
label: t("auth.reset-password.new-password-confirm.text"),
|
|
706
|
+
children: /* @__PURE__ */ jsx(
|
|
707
|
+
PasswordInput,
|
|
708
|
+
{
|
|
709
|
+
id: "newPasswordConfirm",
|
|
710
|
+
placeholder: t(
|
|
711
|
+
`auth.reset-password.new-password-confirm.placeholder.text`
|
|
712
|
+
),
|
|
713
|
+
fieldName: "newPasswordConfirm",
|
|
714
|
+
value: formData.newPasswordConfirm,
|
|
715
|
+
setFormData,
|
|
716
|
+
isDisabled: isRedirecting,
|
|
717
|
+
isError: errors.includes("newPasswordConfirm")
|
|
718
|
+
}
|
|
719
|
+
)
|
|
720
|
+
}
|
|
721
|
+
),
|
|
722
|
+
/* @__PURE__ */ jsx(
|
|
723
|
+
Button2,
|
|
724
|
+
{
|
|
725
|
+
size: "xs",
|
|
726
|
+
variant: "link",
|
|
727
|
+
className: "w-fit",
|
|
728
|
+
isDisabled: isRedirecting,
|
|
729
|
+
children: /* @__PURE__ */ jsx(Link, { href: PATHS.auth.signIn.path, children: t("auth.reset-password.anchor.text") })
|
|
730
|
+
}
|
|
731
|
+
),
|
|
732
|
+
/* @__PURE__ */ jsx(Button2, { type: "submit", isLoading: isRedirecting, children: t("auth.reset-password.button.text") })
|
|
733
|
+
] })
|
|
734
|
+
] }) });
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
function createChangePasswordPage({
|
|
738
|
+
useCommand,
|
|
739
|
+
changePasswordAction
|
|
740
|
+
}) {
|
|
741
|
+
return function ChangePasswordPage() {
|
|
742
|
+
const { t } = useTranslator();
|
|
743
|
+
const router = useRouter();
|
|
744
|
+
const [formData, setFormData] = useState({
|
|
745
|
+
password: "",
|
|
746
|
+
newPassword: "",
|
|
747
|
+
newPasswordConfirm: ""
|
|
748
|
+
});
|
|
749
|
+
const { execute, isRedirecting, errors } = useCommand(
|
|
750
|
+
() => changePasswordAction({
|
|
751
|
+
formData: {
|
|
752
|
+
password: formData.password,
|
|
753
|
+
newPassword: formData.newPassword,
|
|
754
|
+
newPasswordConfirm: formData.newPasswordConfirm
|
|
755
|
+
}
|
|
756
|
+
}),
|
|
757
|
+
{ onSuccess: () => router.push(PATHS.main.dashboard.path) }
|
|
758
|
+
);
|
|
759
|
+
return /* @__PURE__ */ jsx(Form, { className: "mx-auto mt-20 w-96", onSubmit: () => void execute(), children: /* @__PURE__ */ jsxs(Card, { children: [
|
|
760
|
+
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.change-password.text") }) }),
|
|
761
|
+
/* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
|
|
762
|
+
/* @__PURE__ */ jsx(
|
|
763
|
+
Field,
|
|
764
|
+
{
|
|
765
|
+
htmlFor: "password",
|
|
766
|
+
label: t("auth.change-password.password.text"),
|
|
767
|
+
children: /* @__PURE__ */ jsx(
|
|
768
|
+
PasswordInput,
|
|
769
|
+
{
|
|
770
|
+
id: "password",
|
|
771
|
+
placeholder: t(
|
|
772
|
+
"auth.change-password.password.placeholder.text"
|
|
773
|
+
),
|
|
774
|
+
fieldName: "password",
|
|
775
|
+
value: formData.password,
|
|
776
|
+
setFormData,
|
|
777
|
+
isDisabled: isRedirecting,
|
|
778
|
+
isError: errors.includes("password")
|
|
779
|
+
}
|
|
780
|
+
)
|
|
781
|
+
}
|
|
782
|
+
),
|
|
783
|
+
/* @__PURE__ */ jsx(
|
|
784
|
+
Field,
|
|
785
|
+
{
|
|
786
|
+
htmlFor: "newPassword",
|
|
787
|
+
label: t("auth.change-password.new-password.text"),
|
|
788
|
+
children: /* @__PURE__ */ jsx(
|
|
789
|
+
PasswordInput,
|
|
790
|
+
{
|
|
791
|
+
id: "newPassword",
|
|
792
|
+
placeholder: t(
|
|
793
|
+
"auth.change-password.new-password.placeholder.text"
|
|
794
|
+
),
|
|
795
|
+
fieldName: "newPassword",
|
|
796
|
+
value: formData.newPassword,
|
|
797
|
+
setFormData,
|
|
798
|
+
isDisabled: isRedirecting,
|
|
799
|
+
isError: errors.includes("newPassword")
|
|
800
|
+
}
|
|
801
|
+
)
|
|
802
|
+
}
|
|
803
|
+
),
|
|
804
|
+
/* @__PURE__ */ jsx(
|
|
805
|
+
Field,
|
|
806
|
+
{
|
|
807
|
+
htmlFor: "newPasswordConfirm",
|
|
808
|
+
label: t("auth.change-password.new-password-confirm.text"),
|
|
809
|
+
children: /* @__PURE__ */ jsx(
|
|
810
|
+
PasswordInput,
|
|
811
|
+
{
|
|
812
|
+
id: "newPasswordConfirm",
|
|
813
|
+
placeholder: t(
|
|
814
|
+
"auth.change-password.new-password-confirm.placeholder.text"
|
|
815
|
+
),
|
|
816
|
+
fieldName: "newPasswordConfirm",
|
|
817
|
+
value: formData.newPasswordConfirm,
|
|
818
|
+
setFormData,
|
|
819
|
+
isDisabled: isRedirecting,
|
|
820
|
+
isError: errors.includes("newPasswordConfirm")
|
|
821
|
+
}
|
|
822
|
+
)
|
|
823
|
+
}
|
|
824
|
+
),
|
|
825
|
+
/* @__PURE__ */ jsx(
|
|
826
|
+
Button2,
|
|
827
|
+
{
|
|
828
|
+
size: "xs",
|
|
829
|
+
variant: "link",
|
|
830
|
+
className: "w-fit",
|
|
831
|
+
isDisabled: isRedirecting,
|
|
832
|
+
children: /* @__PURE__ */ jsx(Link, { href: PATHS.main.dashboard.path, children: t("auth.change-password.anchor.text") })
|
|
833
|
+
}
|
|
834
|
+
),
|
|
835
|
+
/* @__PURE__ */ jsx(Button2, { type: "submit", isLoading: isRedirecting, children: t("auth.change-password.button.text") }),
|
|
836
|
+
" "
|
|
837
|
+
] })
|
|
838
|
+
] }) });
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
export { AdminProvider, Button2 as Button, Field, FieldBody, Form, Input, PasswordInput, createAdminInitializer, createChangePasswordPage, createEmailUnverifiedPage, createForgotPasswordPage, createRequestInterceptor, createResetPasswordPage, createResponseInterceptor, createSignInPage, createSmartFetch, createUseCommand, createUseQuery, createVerifyEmailPage, handleToast, useAdmin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Spinner, Textarea } from '../../chunk-
|
|
1
|
+
export { Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Spinner, Textarea } from '../../chunk-BVWT2DIB.js';
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as createZod,
|
|
2
|
-
export { R as RawCacheKey,
|
|
1
|
+
import { a as createZod, c as createSchemas, A as ActionContext, b as createTocItemSchema } from '../action-context-yvi5OrMJ.js';
|
|
2
|
+
export { R as RawCacheKey, d as createAdminCommandRepository, e as createAdminQueryRepository, f as createAdminRefreshTokenCommandRepository, g as createAdminRefreshTokenQueryRepository, h as createArgon2Service, i as createAuthMiddleware, j as createAuthUseCases, k as createCacheResult, l as createCookieService, m as createCryptoService, n as createEmailVerificationEmail, o as createExecuteAction, p as createExist, q as createFileCommandRepository, r as createFileQueryRepository, s as createFolderCommandRepository, t as createFolderQueryRepository, u as createForgotPasswordEmail, v as createIpRateLimiter, w as createJwtService, x as createPostCommandRepository, y as createPostQueryRepository, z as createRenderEmailTemplate, B as createSendEmail, C as createSeoMetadataCommandRepository, D as createUnique, E as createVerifyAccessToken, F as createVerifyRefreshToken, G as normalizeCacheKey } from '../action-context-yvi5OrMJ.js';
|
|
3
3
|
import Keyv from 'keyv';
|
|
4
4
|
import * as zod from 'zod';
|
|
5
5
|
import zod__default from 'zod';
|
|
@@ -9,7 +9,7 @@ import nodemailer from 'nodemailer';
|
|
|
9
9
|
import { BaseTranslator, LocaleMessages } from 'intor';
|
|
10
10
|
import { Logger } from 'logry';
|
|
11
11
|
import { NextResponse } from 'next/server';
|
|
12
|
-
import {
|
|
12
|
+
import { R as Result, e as Admin, g as AdminFull, h as AdminRefreshToken, a as Folder, b as FileFull, p as File$1, r as FileType, F as FolderFull, T as TocItem, f as AdminCard, u as PostListCard, c as FileCard, t as Post, w as PostType, v as PostTranslation, P as PostFull } from '../types-BGsFazJr.js';
|
|
13
13
|
import * as zod_v4_core from 'zod/v4/core';
|
|
14
14
|
import '../types-J25u1G6t.js';
|
|
15
15
|
import 'jsonwebtoken';
|
|
@@ -80,73 +80,6 @@ interface CreateExecuteApiParams {
|
|
|
80
80
|
}
|
|
81
81
|
declare function createExecuteApi({ initI18n, logger }: CreateExecuteApiParams): (fn: Api) => Promise<NextResponse<unknown>>;
|
|
82
82
|
|
|
83
|
-
declare const signInValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
|
|
84
|
-
email: zod.ZodEmail;
|
|
85
|
-
password: zod.ZodString;
|
|
86
|
-
}, zod_v4_core.$strip>;
|
|
87
|
-
|
|
88
|
-
type SignInFormData = zod__default.infer<ReturnType<typeof signInValidator>>;
|
|
89
|
-
declare function createSignInAction(ctx: ActionContext): ({ formData, deviceInfo, }: {
|
|
90
|
-
formData: SignInFormData;
|
|
91
|
-
deviceInfo: DeviceInfo;
|
|
92
|
-
}) => Promise<Result<{
|
|
93
|
-
admin: AdminFull;
|
|
94
|
-
}>>;
|
|
95
|
-
|
|
96
|
-
declare function createSignOutAction(ctx: ActionContext): () => Promise<Result<void>>;
|
|
97
|
-
|
|
98
|
-
declare const changePasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
|
|
99
|
-
password: zod.ZodString;
|
|
100
|
-
newPassword: zod.ZodString;
|
|
101
|
-
newPasswordConfirm: zod.ZodString;
|
|
102
|
-
}, zod_v4_core.$strip>;
|
|
103
|
-
|
|
104
|
-
type ChangePasswordFormData = zod__default.infer<ReturnType<typeof changePasswordValidator>>;
|
|
105
|
-
declare function createChangePasswordAction(ctx: ActionContext): ({ formData, }: {
|
|
106
|
-
formData: ChangePasswordFormData;
|
|
107
|
-
}) => Promise<Result<void>>;
|
|
108
|
-
|
|
109
|
-
declare const verifyEmailValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
|
|
110
|
-
email: zod.ZodEmail;
|
|
111
|
-
emailVerificationToken: zod.ZodString;
|
|
112
|
-
}, zod_v4_core.$strip>;
|
|
113
|
-
|
|
114
|
-
type VerifyEmailFormData = zod__default.infer<ReturnType<typeof verifyEmailValidator>>;
|
|
115
|
-
declare function createVerifyEmailAction(ctx: ActionContext): ({ formData, }: {
|
|
116
|
-
formData: VerifyEmailFormData;
|
|
117
|
-
}) => Promise<Result<{
|
|
118
|
-
admin: AdminSafe;
|
|
119
|
-
}>>;
|
|
120
|
-
|
|
121
|
-
declare const emailUnverifiedValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
|
|
122
|
-
email: zod.ZodEmail;
|
|
123
|
-
}, zod_v4_core.$strip>;
|
|
124
|
-
|
|
125
|
-
type EmailUnverifiedFormData = zod__default.infer<ReturnType<typeof emailUnverifiedValidator>>;
|
|
126
|
-
declare function createEmailUnverifiedAction(ctx: ActionContext): ({ formData, }: {
|
|
127
|
-
formData: EmailUnverifiedFormData;
|
|
128
|
-
}) => Promise<Result<void>>;
|
|
129
|
-
|
|
130
|
-
declare const forgetPasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
|
|
131
|
-
email: zod.ZodEmail;
|
|
132
|
-
}, zod_v4_core.$strip>;
|
|
133
|
-
|
|
134
|
-
type ForgotPasswordFormData = zod__default.infer<ReturnType<typeof forgetPasswordValidator>>;
|
|
135
|
-
declare function createForgotPasswordAction(ctx: ActionContext): ({ formData, }: {
|
|
136
|
-
formData: ForgotPasswordFormData;
|
|
137
|
-
}) => Promise<Result<void>>;
|
|
138
|
-
|
|
139
|
-
declare const resetPasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
|
|
140
|
-
passwordResetToken: zod.ZodString;
|
|
141
|
-
newPassword: zod.ZodString;
|
|
142
|
-
newPasswordConfirm: zod.ZodString;
|
|
143
|
-
}, zod_v4_core.$strip>;
|
|
144
|
-
|
|
145
|
-
type ResetPasswordFormData = zod__default.infer<ReturnType<typeof resetPasswordValidator>>;
|
|
146
|
-
declare function createResetPasswordAction(ctx: ActionContext): ({ formData, }: {
|
|
147
|
-
formData: ResetPasswordFormData;
|
|
148
|
-
}) => Promise<Result<void>>;
|
|
149
|
-
|
|
150
83
|
declare const adminCreateValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
|
|
151
84
|
role: zod.ZodEnum<{
|
|
152
85
|
SUPER_ADMIN: "SUPER_ADMIN";
|
|
@@ -1608,4 +1541,4 @@ declare class ServerError extends Error {
|
|
|
1608
1541
|
static internalServerError(): ServerError;
|
|
1609
1542
|
}
|
|
1610
1543
|
|
|
1611
|
-
export { ADMIN_ORDER_BY, ActionContext, type AdminCreateFormData, type AdminUpdateFormData, type
|
|
1544
|
+
export { ADMIN_ORDER_BY, ActionContext, type AdminCreateFormData, type AdminUpdateFormData, type FileCreateFormData, type FileCreateManyFormData, type FileUpdateFormData, type FolderCreateFormData, type FolderUpdateFormData, ORDER_BY, POST_ORDER_BY, type PostCreateFormData, type PostUpdateFormData, type SeoMetadataUpsertFormData, ServerError, createAdminCreateAction, createAdminDeleteAction, createAdminFindFullAction, createAdminFindListCardsAction, createAdminRefreshTokenDeleteAction, createAdminRefreshTokenFindManyAction, createAdminUpdateAction, createCache, createExecuteApi, createFileCreateAction, createFileCreateManyAction, createFileFindFullAction, createFileFindListCardsAction, createFilePurgeManyAction, createFileRestoreManyAction, createFileSchema, createFileSoftDeleteAction, createFileSoftDeleteManyAction, createFileUpdateAction, createFolderCreateAction, createFolderDeleteAction, createFolderFindFullAction, createFolderFindListCardsAction, createFolderUpdateAction, createMultiFileSchema, createPostCreateAction, createPostDeleteAction, createPostFindAction, createPostFindFullAction, createPostFindListCardsAction, createPostFindManyAction, createPostUpdateAction, createSchemas, createSeoMetadataUpsertAction, createTocItemSchema, createTransporter, createZod };
|
package/dist/server/index.js
CHANGED
|
@@ -2095,313 +2095,6 @@ function createVerifyRefreshToken({
|
|
|
2095
2095
|
};
|
|
2096
2096
|
}
|
|
2097
2097
|
|
|
2098
|
-
// src/server/interfaces/actions/auth/sign-in/sign-in-validator.ts
|
|
2099
|
-
var signInValidator = (schemas) => schemas.z.object({
|
|
2100
|
-
email: schemas.email(),
|
|
2101
|
-
password: schemas.password()
|
|
2102
|
-
});
|
|
2103
|
-
|
|
2104
|
-
// src/server/interfaces/actions/auth/sign-in/create-sign-in-action.ts
|
|
2105
|
-
function createSignInAction(ctx) {
|
|
2106
|
-
return async function signInAction({
|
|
2107
|
-
formData,
|
|
2108
|
-
deviceInfo
|
|
2109
|
-
}) {
|
|
2110
|
-
const {
|
|
2111
|
-
repositories: {
|
|
2112
|
-
adminQueryRepository,
|
|
2113
|
-
adminRefreshTokenCommandRepository
|
|
2114
|
-
},
|
|
2115
|
-
useCases: { authUseCases },
|
|
2116
|
-
action: { executeAction, ipRateLimiter },
|
|
2117
|
-
http: { headers },
|
|
2118
|
-
schemas: { schemas }
|
|
2119
|
-
} = ctx;
|
|
2120
|
-
return executeAction(
|
|
2121
|
-
async () => {
|
|
2122
|
-
await ipRateLimiter({ key: ["sign-in"] });
|
|
2123
|
-
const { email, password } = await signInValidator(schemas).parseAsync(formData);
|
|
2124
|
-
const verified = await authUseCases.verifyCredentials({
|
|
2125
|
-
email,
|
|
2126
|
-
password
|
|
2127
|
-
});
|
|
2128
|
-
const admin = await adminQueryRepository.findFull({
|
|
2129
|
-
id: verified.id
|
|
2130
|
-
});
|
|
2131
|
-
if (!admin) throw ServerError.notFound();
|
|
2132
|
-
await authUseCases.refreshTokens({
|
|
2133
|
-
admin,
|
|
2134
|
-
deviceInfo,
|
|
2135
|
-
ip: (await headers()).get("x-forwarded-for") || "unknown"
|
|
2136
|
-
});
|
|
2137
|
-
await adminRefreshTokenCommandRepository.deleteManyByExpired();
|
|
2138
|
-
return {
|
|
2139
|
-
i18nKey: "ok.sign-in-ok",
|
|
2140
|
-
data: { admin }
|
|
2141
|
-
};
|
|
2142
|
-
},
|
|
2143
|
-
{ type: "command" }
|
|
2144
|
-
);
|
|
2145
|
-
};
|
|
2146
|
-
}
|
|
2147
|
-
|
|
2148
|
-
// src/server/interfaces/actions/auth/sign-out/create-sign-out-action.ts
|
|
2149
|
-
function createSignOutAction(ctx) {
|
|
2150
|
-
const {
|
|
2151
|
-
services: { cryptoService, cookieService },
|
|
2152
|
-
repositories: { adminRefreshTokenCommandRepository },
|
|
2153
|
-
action: { executeAction },
|
|
2154
|
-
config: { accessTokenName, refreshTokenName }
|
|
2155
|
-
} = ctx;
|
|
2156
|
-
return async function signOutAction() {
|
|
2157
|
-
return executeAction(
|
|
2158
|
-
async () => {
|
|
2159
|
-
let token;
|
|
2160
|
-
try {
|
|
2161
|
-
token = await cookieService.getSignedCookie({
|
|
2162
|
-
name: refreshTokenName
|
|
2163
|
-
});
|
|
2164
|
-
} catch {
|
|
2165
|
-
}
|
|
2166
|
-
if (token) {
|
|
2167
|
-
await adminRefreshTokenCommandRepository.delete({
|
|
2168
|
-
tokenHash: cryptoService.hash(token)
|
|
2169
|
-
});
|
|
2170
|
-
}
|
|
2171
|
-
await cookieService.delete({ name: accessTokenName });
|
|
2172
|
-
await cookieService.delete({ name: refreshTokenName });
|
|
2173
|
-
return {
|
|
2174
|
-
i18nKey: "ok.sign-out-ok"
|
|
2175
|
-
};
|
|
2176
|
-
},
|
|
2177
|
-
{ type: "command" }
|
|
2178
|
-
);
|
|
2179
|
-
};
|
|
2180
|
-
}
|
|
2181
|
-
|
|
2182
|
-
// src/server/interfaces/actions/auth/verify/create-verify-action.ts
|
|
2183
|
-
function createVerifyAction(ctx) {
|
|
2184
|
-
const {
|
|
2185
|
-
middlewares: { authMiddleware },
|
|
2186
|
-
action: { executeAction, ipRateLimiter }
|
|
2187
|
-
} = ctx;
|
|
2188
|
-
return async function verifyAction() {
|
|
2189
|
-
return executeAction(async () => {
|
|
2190
|
-
await ipRateLimiter({ key: ["verify"], maxAttempts: 60 });
|
|
2191
|
-
const admin = await authMiddleware.authenticate();
|
|
2192
|
-
return {
|
|
2193
|
-
data: { admin }
|
|
2194
|
-
};
|
|
2195
|
-
});
|
|
2196
|
-
};
|
|
2197
|
-
}
|
|
2198
|
-
|
|
2199
|
-
// src/server/interfaces/actions/auth/change-password/change-password-validator.ts
|
|
2200
|
-
var changePasswordValidator = (schemas) => schemas.z.object({
|
|
2201
|
-
password: schemas.password(),
|
|
2202
|
-
newPassword: schemas.password(),
|
|
2203
|
-
newPasswordConfirm: schemas.password()
|
|
2204
|
-
}).superRefine((data, ctx) => {
|
|
2205
|
-
if (data.newPassword !== data.newPasswordConfirm) {
|
|
2206
|
-
ctx.addIssue({
|
|
2207
|
-
code: "custom",
|
|
2208
|
-
params: { i18nKey: "validator.password-confirm" },
|
|
2209
|
-
path: ["newPassword"]
|
|
2210
|
-
});
|
|
2211
|
-
ctx.addIssue({
|
|
2212
|
-
code: "custom",
|
|
2213
|
-
params: { i18nKey: "validator.password-confirm" },
|
|
2214
|
-
path: ["newPasswordConfirm"]
|
|
2215
|
-
});
|
|
2216
|
-
}
|
|
2217
|
-
});
|
|
2218
|
-
|
|
2219
|
-
// src/server/interfaces/actions/auth/change-password/create-change-password-action.ts
|
|
2220
|
-
function createChangePasswordAction(ctx) {
|
|
2221
|
-
return async function changePasswordAction({
|
|
2222
|
-
formData
|
|
2223
|
-
}) {
|
|
2224
|
-
const {
|
|
2225
|
-
action: { executeAction, ipRateLimiter },
|
|
2226
|
-
useCases: { authUseCases },
|
|
2227
|
-
middlewares: { authMiddleware },
|
|
2228
|
-
schemas: { schemas }
|
|
2229
|
-
} = ctx;
|
|
2230
|
-
return executeAction(
|
|
2231
|
-
async () => {
|
|
2232
|
-
await ipRateLimiter({ key: ["change-password"] });
|
|
2233
|
-
const { email } = await authMiddleware.authenticate();
|
|
2234
|
-
const { password, newPassword } = await changePasswordValidator(schemas).parseAsync(formData);
|
|
2235
|
-
await authUseCases.verifyCredentials({ email, password });
|
|
2236
|
-
await authUseCases.updatePassword({ email, password: newPassword });
|
|
2237
|
-
return {
|
|
2238
|
-
i18nKey: "ok.change-password-ok"
|
|
2239
|
-
};
|
|
2240
|
-
},
|
|
2241
|
-
{ type: "command" }
|
|
2242
|
-
);
|
|
2243
|
-
};
|
|
2244
|
-
}
|
|
2245
|
-
|
|
2246
|
-
// src/server/interfaces/actions/auth/verify-email/verify-email-validator.ts
|
|
2247
|
-
var verifyEmailValidator = (schemas) => schemas.z.object({
|
|
2248
|
-
email: schemas.email(),
|
|
2249
|
-
emailVerificationToken: schemas.z.string().trim().max(1e3)
|
|
2250
|
-
});
|
|
2251
|
-
|
|
2252
|
-
// src/server/interfaces/actions/auth/verify-email/create-verify-email-action.ts
|
|
2253
|
-
function createVerifyEmailAction(ctx) {
|
|
2254
|
-
return async function verifyEmailAction({
|
|
2255
|
-
formData
|
|
2256
|
-
}) {
|
|
2257
|
-
const {
|
|
2258
|
-
repositories: { adminQueryRepository },
|
|
2259
|
-
useCases: { authUseCases },
|
|
2260
|
-
action: { executeAction, ipRateLimiter },
|
|
2261
|
-
schemas: { schemas }
|
|
2262
|
-
} = ctx;
|
|
2263
|
-
return executeAction(
|
|
2264
|
-
async () => {
|
|
2265
|
-
await ipRateLimiter({ key: ["verify-email"] });
|
|
2266
|
-
const { email, emailVerificationToken } = await verifyEmailValidator(schemas).parseAsync(formData);
|
|
2267
|
-
const admin = await adminQueryRepository.find({ email });
|
|
2268
|
-
if (!admin) throw new ServerError({ i18nKey: "error.email-not-found" });
|
|
2269
|
-
await authUseCases.verifyEmailAndUpdate({
|
|
2270
|
-
token: emailVerificationToken || "",
|
|
2271
|
-
admin
|
|
2272
|
-
});
|
|
2273
|
-
return {
|
|
2274
|
-
i18nKey: "ok.verify-email-ok",
|
|
2275
|
-
data: { admin }
|
|
2276
|
-
};
|
|
2277
|
-
},
|
|
2278
|
-
{ type: "command" }
|
|
2279
|
-
);
|
|
2280
|
-
};
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2283
|
-
// src/server/interfaces/actions/auth/email-unverifired/email-unverifired-validator.ts
|
|
2284
|
-
var emailUnverifiedValidator = (schemas) => schemas.z.object({
|
|
2285
|
-
email: schemas.email()
|
|
2286
|
-
});
|
|
2287
|
-
|
|
2288
|
-
// src/server/interfaces/actions/auth/email-unverifired/create-email-unverifired-action.ts
|
|
2289
|
-
function createEmailUnverifiedAction(ctx) {
|
|
2290
|
-
return async function emailUnverifiedAction({
|
|
2291
|
-
formData
|
|
2292
|
-
}) {
|
|
2293
|
-
const {
|
|
2294
|
-
repositories: { adminQueryRepository },
|
|
2295
|
-
action: { executeAction, ipRateLimiter },
|
|
2296
|
-
emails: { emailVerificationEmail },
|
|
2297
|
-
schemas: { schemas }
|
|
2298
|
-
} = ctx;
|
|
2299
|
-
return executeAction(
|
|
2300
|
-
async (translator) => {
|
|
2301
|
-
await ipRateLimiter({
|
|
2302
|
-
key: ["email-unverified"],
|
|
2303
|
-
maxAttempts: 2,
|
|
2304
|
-
timeWindow: 60
|
|
2305
|
-
});
|
|
2306
|
-
const { email } = await emailUnverifiedValidator(schemas).parseAsync(formData);
|
|
2307
|
-
const admin = await adminQueryRepository.find({ email });
|
|
2308
|
-
if (!admin) throw new ServerError({ i18nKey: "error.email-not-found" });
|
|
2309
|
-
void emailVerificationEmail.send({ translator, admin });
|
|
2310
|
-
return {
|
|
2311
|
-
i18nKey: "ok.email-unverified-ok"
|
|
2312
|
-
};
|
|
2313
|
-
},
|
|
2314
|
-
{ type: "command" }
|
|
2315
|
-
);
|
|
2316
|
-
};
|
|
2317
|
-
}
|
|
2318
|
-
|
|
2319
|
-
// src/server/interfaces/actions/auth/forgot-password/forgot-password-validator.ts
|
|
2320
|
-
var forgetPasswordValidator = (schemas) => schemas.z.object({
|
|
2321
|
-
email: schemas.email()
|
|
2322
|
-
});
|
|
2323
|
-
|
|
2324
|
-
// src/server/interfaces/actions/auth/forgot-password/create-forgot-password-action.ts
|
|
2325
|
-
function createForgotPasswordAction(ctx) {
|
|
2326
|
-
return async function forgotPasswordAction({
|
|
2327
|
-
formData
|
|
2328
|
-
}) {
|
|
2329
|
-
const {
|
|
2330
|
-
repositories: { adminQueryRepository },
|
|
2331
|
-
action: { executeAction, ipRateLimiter },
|
|
2332
|
-
emails: { forgotPasswordEmail },
|
|
2333
|
-
schemas: { schemas }
|
|
2334
|
-
} = ctx;
|
|
2335
|
-
return executeAction(
|
|
2336
|
-
async (translator) => {
|
|
2337
|
-
await ipRateLimiter({
|
|
2338
|
-
key: ["forget-password"],
|
|
2339
|
-
maxAttempts: 2,
|
|
2340
|
-
timeWindow: 60
|
|
2341
|
-
});
|
|
2342
|
-
const { email } = await forgetPasswordValidator(schemas).parseAsync(formData);
|
|
2343
|
-
const admin = await adminQueryRepository.find({ email });
|
|
2344
|
-
if (!admin) throw new ServerError({ i18nKey: "error.email-not-found" });
|
|
2345
|
-
void forgotPasswordEmail.send({ translator, admin });
|
|
2346
|
-
return {
|
|
2347
|
-
i18nKey: "ok.forgot-password-ok"
|
|
2348
|
-
};
|
|
2349
|
-
},
|
|
2350
|
-
{ type: "command" }
|
|
2351
|
-
);
|
|
2352
|
-
};
|
|
2353
|
-
}
|
|
2354
|
-
|
|
2355
|
-
// src/server/interfaces/actions/auth/reset-password/reset-password-validator.ts
|
|
2356
|
-
var resetPasswordValidator = (schemas) => schemas.z.object({
|
|
2357
|
-
passwordResetToken: schemas.z.string().trim().max(1e3),
|
|
2358
|
-
newPassword: schemas.password(),
|
|
2359
|
-
newPasswordConfirm: schemas.password()
|
|
2360
|
-
}).superRefine((data, ctx) => {
|
|
2361
|
-
if (data.newPassword !== data.newPasswordConfirm) {
|
|
2362
|
-
ctx.addIssue({
|
|
2363
|
-
code: "custom",
|
|
2364
|
-
message: "custom.password-confirm",
|
|
2365
|
-
path: ["newPassword"]
|
|
2366
|
-
});
|
|
2367
|
-
ctx.addIssue({
|
|
2368
|
-
code: "custom",
|
|
2369
|
-
message: "custom.password-confirm",
|
|
2370
|
-
path: ["newPasswordConfirm"]
|
|
2371
|
-
});
|
|
2372
|
-
}
|
|
2373
|
-
});
|
|
2374
|
-
|
|
2375
|
-
// src/server/interfaces/actions/auth/reset-password/create-reset-password-action.ts
|
|
2376
|
-
function createResetPasswordAction(ctx) {
|
|
2377
|
-
return async function ResetPasswordAction({
|
|
2378
|
-
formData
|
|
2379
|
-
}) {
|
|
2380
|
-
const {
|
|
2381
|
-
useCases: { authUseCases },
|
|
2382
|
-
action: { executeAction, ipRateLimiter },
|
|
2383
|
-
schemas: { schemas }
|
|
2384
|
-
} = ctx;
|
|
2385
|
-
return executeAction(
|
|
2386
|
-
async () => {
|
|
2387
|
-
await ipRateLimiter({ key: ["reset-password"] });
|
|
2388
|
-
const { newPassword, passwordResetToken } = await resetPasswordValidator(schemas).parseAsync(formData);
|
|
2389
|
-
const decoded = authUseCases.verifyPasswordResetToken({
|
|
2390
|
-
token: passwordResetToken
|
|
2391
|
-
});
|
|
2392
|
-
await authUseCases.updatePassword({
|
|
2393
|
-
email: decoded.email,
|
|
2394
|
-
password: newPassword
|
|
2395
|
-
});
|
|
2396
|
-
return {
|
|
2397
|
-
i18nKey: "ok.reset-password-ok"
|
|
2398
|
-
};
|
|
2399
|
-
},
|
|
2400
|
-
{ type: "command" }
|
|
2401
|
-
);
|
|
2402
|
-
};
|
|
2403
|
-
}
|
|
2404
|
-
|
|
2405
2098
|
// src/server/interfaces/actions/resources/admin/commands/create/admin-create-validator.ts
|
|
2406
2099
|
var adminCreateValidator = (schemas) => schemas.z.object({
|
|
2407
2100
|
// core
|
|
@@ -4348,4 +4041,4 @@ function createForgotPasswordEmail({
|
|
|
4348
4041
|
};
|
|
4349
4042
|
}
|
|
4350
4043
|
|
|
4351
|
-
export { ADMIN_ORDER_BY, ORDER_BY, POST_ORDER_BY, ServerError, createAdminCommandRepository, createAdminCreateAction, createAdminDeleteAction, createAdminFindFullAction, createAdminFindListCardsAction, createAdminQueryRepository, createAdminRefreshTokenCommandRepository, createAdminRefreshTokenDeleteAction, createAdminRefreshTokenFindManyAction, createAdminRefreshTokenQueryRepository, createAdminUpdateAction, createArgon2Service, createAuthMiddleware, createAuthUseCases, createCache, createCacheResult,
|
|
4044
|
+
export { ADMIN_ORDER_BY, ORDER_BY, POST_ORDER_BY, ServerError, createAdminCommandRepository, createAdminCreateAction, createAdminDeleteAction, createAdminFindFullAction, createAdminFindListCardsAction, createAdminQueryRepository, createAdminRefreshTokenCommandRepository, createAdminRefreshTokenDeleteAction, createAdminRefreshTokenFindManyAction, createAdminRefreshTokenQueryRepository, createAdminUpdateAction, createArgon2Service, createAuthMiddleware, createAuthUseCases, createCache, createCacheResult, createCookieService, createCryptoService, createEmailVerificationEmail, createExecuteAction, createExecuteApi, createExist, createFileCommandRepository, createFileCreateAction, createFileCreateManyAction, createFileFindFullAction, createFileFindListCardsAction, createFilePurgeManyAction, createFileQueryRepository, createFileRestoreManyAction, createFileSchema, createFileSoftDeleteAction, createFileSoftDeleteManyAction, createFileUpdateAction, createFolderCommandRepository, createFolderCreateAction, createFolderDeleteAction, createFolderFindFullAction, createFolderFindListCardsAction, createFolderQueryRepository, createFolderUpdateAction, createForgotPasswordEmail, createIpRateLimiter, createJwtService, createMultiFileSchema, createPostCommandRepository, createPostCreateAction, createPostDeleteAction, createPostFindAction, createPostFindFullAction, createPostFindListCardsAction, createPostFindManyAction, createPostQueryRepository, createPostUpdateAction, createRenderEmailTemplate, createSchemas, createSendEmail, createSeoMetadataCommandRepository, createSeoMetadataUpsertAction, createTocItemSchema, createTransporter, createUnique, createVerifyAccessToken, createVerifyRefreshToken, createZod, normalizeCacheKey };
|