create-mohit-next 1.0.0 → 2.0.0
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/README.md +96 -65
- package/index.js +195 -195
- package/lib/features.js +358 -0
- package/lib/scaffold.js +471 -0
- package/package.json +10 -6
- package/templates/common/_editorconfig +12 -0
- package/templates/common/_gitattributes +5 -0
- package/templates/common/_github/dependabot.yml +14 -0
- package/templates/common/_github/workflows/ci.yml +66 -0
- package/templates/common/_husky/commit-msg +1 -0
- package/templates/common/_husky/pre-commit +1 -0
- package/templates/common/_nvmrc +1 -0
- package/{template → templates/common}/_prettierignore +4 -0
- package/templates/common/commitlint.config.mjs +10 -0
- package/templates/next/README.md +328 -0
- package/{template → templates/next}/_env.example +10 -1
- package/{template → templates/next}/_gitignore +8 -0
- package/templates/next/e2e/rbac.spec.ts +69 -0
- package/templates/next/e2e/server.mjs +35 -0
- package/{template → templates/next}/eslint.config.mjs +12 -0
- package/{template → templates/next}/next.config.ts +2 -0
- package/{template → templates/next}/package.json +18 -3
- package/templates/next/playwright.config.ts +30 -0
- package/templates/next/scripts/seed.ts +111 -0
- package/templates/next/src/app/(app)/admin/audit/page.tsx +99 -0
- package/templates/next/src/app/(app)/admin/page.tsx +92 -0
- package/{template → templates/next}/src/app/(app)/dashboard/page.tsx +22 -29
- package/{template → templates/next}/src/app/(app)/error.tsx +7 -7
- package/{template → templates/next}/src/app/(app)/layout.tsx +25 -2
- package/templates/next/src/app/(app)/reports/page.tsx +128 -0
- package/templates/next/src/app/(app)/settings/page.tsx +66 -0
- package/templates/next/src/app/(auth)/forgot-password/page.tsx +17 -0
- package/templates/next/src/app/(auth)/layout.tsx +18 -0
- package/{template → templates/next}/src/app/(auth)/register/page.tsx +2 -4
- package/templates/next/src/app/(auth)/reset-password/page.tsx +18 -0
- package/templates/next/src/app/api/account/password/route.ts +45 -0
- package/templates/next/src/app/api/account/route.ts +25 -0
- package/templates/next/src/app/api/account/sessions/route.ts +12 -0
- package/templates/next/src/app/api/admin/audit/route.ts +13 -0
- package/{template → templates/next}/src/app/api/admin/users/[id]/route.ts +25 -4
- package/templates/next/src/app/api/auth/forgot-password/route.ts +47 -0
- package/{template → templates/next}/src/app/api/auth/login/route.ts +19 -2
- package/{template → templates/next}/src/app/api/auth/me/route.ts +4 -2
- package/{template → templates/next}/src/app/api/auth/register/route.ts +38 -4
- package/templates/next/src/app/api/auth/resend-verification/route.ts +25 -0
- package/templates/next/src/app/api/auth/reset-password/route.ts +43 -0
- package/templates/next/src/app/api/auth/verify-email/route.ts +29 -0
- package/{template → templates/next}/src/app/forbidden/page.tsx +11 -13
- package/{template → templates/next}/src/app/layout.tsx +9 -6
- package/templates/next/src/app/not-found.tsx +20 -0
- package/templates/next/src/app/opengraph-image.tsx +49 -0
- package/templates/next/src/app/page.tsx +165 -0
- package/templates/next/src/app/robots.ts +15 -0
- package/templates/next/src/app/sitemap.ts +13 -0
- package/templates/next/src/app/verify-email/page.tsx +23 -0
- package/templates/next/src/components/admin/user-actions.tsx +124 -0
- package/templates/next/src/components/admin/users-data-table.tsx +221 -0
- package/templates/next/src/components/admin/users-table.tsx +67 -0
- package/{template → templates/next}/src/components/auth/auth-card.tsx +8 -8
- package/templates/next/src/components/auth/forgot-password-form.tsx +76 -0
- package/templates/next/src/components/auth/form-field.tsx +40 -0
- package/{template → templates/next}/src/components/auth/login-form.tsx +14 -9
- package/templates/next/src/components/auth/password-input.tsx +43 -0
- package/{template → templates/next}/src/components/auth/register-form.tsx +22 -19
- package/templates/next/src/components/auth/reset-password-form.tsx +80 -0
- package/{template → templates/next}/src/components/auth/session-refresher.tsx +1 -1
- package/templates/next/src/components/auth/verify-email-banner.tsx +43 -0
- package/templates/next/src/components/auth/verify-email-status.tsx +44 -0
- package/templates/next/src/components/layout/nav-links.tsx +37 -0
- package/templates/next/src/components/layout/navbar.tsx +27 -0
- package/templates/next/src/components/layout/page-header.tsx +21 -0
- package/templates/next/src/components/layout/sidebar.tsx +83 -0
- package/templates/next/src/components/layout/skeletons.tsx +57 -0
- package/templates/next/src/components/layout/user-menu.tsx +118 -0
- package/{template → templates/next}/src/components/logo.tsx +3 -6
- package/{template → templates/next}/src/components/reports/animated-bar.tsx +1 -5
- package/templates/next/src/components/reports/role-chart.tsx +61 -0
- package/templates/next/src/components/reports/signups-chart.tsx +64 -0
- package/templates/next/src/components/role-badge.tsx +11 -0
- package/templates/next/src/components/settings/password-form.tsx +80 -0
- package/templates/next/src/components/settings/profile-form.tsx +63 -0
- package/templates/next/src/components/settings/sessions-card.tsx +70 -0
- package/templates/next/src/components/theme-toggle.tsx +61 -0
- package/templates/next/src/config/rbac.test.ts +89 -0
- package/{template → templates/next}/src/config/rbac.ts +35 -5
- package/{template → templates/next}/src/lib/api.ts +40 -4
- package/templates/next/src/lib/audit.ts +66 -0
- package/{template → templates/next}/src/lib/auth.ts +10 -2
- package/{template → templates/next}/src/lib/dal.ts +8 -5
- package/templates/next/src/lib/email-templates.ts +55 -0
- package/templates/next/src/lib/email.ts +53 -0
- package/templates/next/src/lib/env.ts +90 -0
- package/templates/next/src/lib/password-strength.test.ts +20 -0
- package/templates/next/src/lib/password-strength.ts +24 -0
- package/templates/next/src/lib/rate-limit.test.ts +47 -0
- package/templates/next/src/lib/rate-limit.ts +70 -0
- package/templates/next/src/lib/redirect.test.ts +23 -0
- package/{template → templates/next}/src/lib/session.ts +5 -1
- package/templates/next/src/lib/theme.ts +32 -0
- package/templates/next/src/lib/tokens.ts +63 -0
- package/{template → templates/next}/src/lib/users.ts +49 -12
- package/templates/next/src/lib/validations/account.ts +20 -0
- package/templates/next/src/lib/validations/auth.test.ts +39 -0
- package/{template → templates/next}/src/lib/validations/auth.ts +24 -2
- package/templates/next/src/models/audit-log.ts +33 -0
- package/templates/next/src/models/auth-token.ts +26 -0
- package/{template → templates/next}/src/models/user.ts +5 -0
- package/{template → templates/next}/src/proxy.ts +1 -1
- package/templates/next/src/styles/app.css +1092 -0
- package/{template → templates/next}/src/types/user.ts +3 -0
- package/templates/next/vitest.config.mts +13 -0
- package/templates/styles/css.css +580 -0
- package/templates/styles/tailwind.css +140 -0
- package/templates/ui/css/components/alert-dialog.tsx +172 -0
- package/templates/ui/css/components/avatar.tsx +17 -0
- package/templates/ui/css/components/badge.tsx +18 -0
- package/templates/ui/css/components/button.tsx +41 -0
- package/templates/ui/css/components/card.tsx +33 -0
- package/templates/ui/css/components/dropdown-menu.tsx +230 -0
- package/templates/ui/css/components/input.tsx +7 -0
- package/templates/ui/css/components/label.tsx +7 -0
- package/templates/ui/css/components/native-select.tsx +23 -0
- package/templates/ui/css/components/skeleton.tsx +7 -0
- package/templates/ui/css/components/slot.tsx +30 -0
- package/templates/ui/css/components/table.tsx +31 -0
- package/templates/ui/css/utils.ts +16 -0
- package/templates/ui/shadcn/components/alert-dialog.tsx +199 -0
- package/templates/ui/shadcn/components/avatar.tsx +111 -0
- package/templates/ui/shadcn/components/dropdown-menu.tsx +268 -0
- package/templates/ui/shadcn/components/table.tsx +115 -0
- package/templates/ui/tailwind/components/alert-dialog.tsx +177 -0
- package/templates/ui/tailwind/components/avatar.tsx +36 -0
- package/templates/ui/tailwind/components/badge.tsx +29 -0
- package/templates/ui/tailwind/components/button.tsx +65 -0
- package/templates/ui/tailwind/components/card.tsx +70 -0
- package/templates/ui/tailwind/components/dropdown-menu.tsx +236 -0
- package/templates/ui/tailwind/components/input.tsx +17 -0
- package/templates/ui/tailwind/components/label.tsx +16 -0
- package/templates/ui/tailwind/components/native-select.tsx +32 -0
- package/templates/ui/tailwind/components/skeleton.tsx +13 -0
- package/templates/ui/tailwind/components/slot.tsx +34 -0
- package/templates/ui/tailwind/components/table.tsx +56 -0
- package/templates/ui/tailwind/utils.ts +1 -0
- package/templates/vite/Dockerfile +29 -0
- package/templates/vite/README.md +142 -0
- package/templates/vite/_dockerignore +14 -0
- package/templates/vite/_env.example +8 -0
- package/templates/vite/_gitignore +37 -0
- package/templates/vite/e2e/app.spec.ts +41 -0
- package/templates/vite/index.html +32 -0
- package/templates/vite/nginx.conf +26 -0
- package/templates/vite/package.json +61 -0
- package/templates/vite/playwright.config.ts +27 -0
- package/templates/vite/public/favicon.svg +1 -0
- package/templates/vite/src/App.test.tsx +28 -0
- package/templates/vite/src/App.tsx +26 -0
- package/templates/vite/src/components/home.tsx +121 -0
- package/templates/vite/src/components/layout/root-layout.tsx +18 -0
- package/templates/vite/src/components/layout/site-footer.tsx +10 -0
- package/templates/vite/src/components/layout/site-header.tsx +49 -0
- package/templates/vite/src/components/theme-toggle.tsx +90 -0
- package/templates/vite/src/env.ts +36 -0
- package/templates/vite/src/lib/theme.ts +26 -0
- package/templates/vite/src/main.tsx +13 -0
- package/templates/vite/src/pages/about.tsx +52 -0
- package/templates/vite/src/pages/not-found.tsx +33 -0
- package/templates/vite/src/router.ts +24 -0
- package/templates/vite/src/styles/app.css +281 -0
- package/templates/vite/src/test/setup.ts +21 -0
- package/templates/vite/tsconfig.app.json +31 -0
- package/templates/vite/tsconfig.json +7 -0
- package/templates/vite/tsconfig.node.json +23 -0
- package/templates/vite/vite.config.ts +30 -0
- package/template/README.md +0 -262
- package/template/_prettierrc +0 -9
- package/template/components.json +0 -25
- package/template/src/app/(app)/admin/page.tsx +0 -53
- package/template/src/app/(app)/reports/page.tsx +0 -109
- package/template/src/app/(auth)/layout.tsx +0 -22
- package/template/src/app/not-found.tsx +0 -18
- package/template/src/app/page.tsx +0 -187
- package/template/src/components/admin/users-table.tsx +0 -162
- package/template/src/components/auth/form-field.tsx +0 -32
- package/template/src/components/layout/logout-button.tsx +0 -34
- package/template/src/components/layout/navbar.tsx +0 -67
- package/template/src/components/layout/page-header.tsx +0 -21
- package/template/src/components/layout/skeletons.tsx +0 -35
- package/template/src/components/role-badge.tsx +0 -17
- package/template/src/components/theme-toggle.tsx +0 -25
- package/template/src/lib/env.ts +0 -36
- package/template/src/lib/theme.ts +0 -8
- /package/{template → templates/next}/AGENTS.md +0 -0
- /package/{template → templates/next}/Dockerfile +0 -0
- /package/{template → templates/next}/_dockerignore +0 -0
- /package/{template → templates/next}/docker-compose.yml +0 -0
- /package/{template → templates/next}/public/robots.txt +0 -0
- /package/{template → templates/next}/src/app/(app)/loading.tsx +0 -0
- /package/{template → templates/next}/src/app/(auth)/login/page.tsx +0 -0
- /package/{template → templates/next}/src/app/api/admin/users/route.ts +0 -0
- /package/{template → templates/next}/src/app/api/auth/logout/route.ts +0 -0
- /package/{template → templates/next}/src/app/api/health/route.ts +0 -0
- /package/{template → templates/next}/src/app/favicon.ico +0 -0
- /package/{template → templates/next}/src/components/auth/can.tsx +0 -0
- /package/{template → templates/next}/src/components/motion/fade-in.tsx +0 -0
- /package/{template → templates/next}/src/components/providers/user-provider.tsx +0 -0
- /package/{template → templates/next}/src/config/site.ts +0 -0
- /package/{template → templates/next}/src/lib/db.ts +0 -0
- /package/{template → templates/next}/src/lib/http.ts +0 -0
- /package/{template → templates/next}/src/lib/redirect.ts +0 -0
- /package/{template → templates/next}/src/lib/validations/user.ts +0 -0
- /package/{template → templates/next}/tsconfig.json +0 -0
- /package/{template/src/app/globals.css → templates/styles/shadcn.css} +0 -0
- /package/{template/src/components/ui → templates/ui/shadcn/components}/badge.tsx +0 -0
- /package/{template/src/components/ui → templates/ui/shadcn/components}/button.tsx +0 -0
- /package/{template/src/components/ui → templates/ui/shadcn/components}/card.tsx +0 -0
- /package/{template/src/components/ui → templates/ui/shadcn/components}/input.tsx +0 -0
- /package/{template/src/components/ui → templates/ui/shadcn/components}/label.tsx +0 -0
- /package/{template/src/components/ui → templates/ui/shadcn/components}/native-select.tsx +0 -0
- /package/{template/src/components/ui → templates/ui/shadcn/components}/skeleton.tsx +0 -0
- /package/{template/src/lib → templates/ui/shadcn}/utils.ts +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
2
|
+
|
|
3
|
+
import { AuthCard } from "@/components/auth/auth-card";
|
|
4
|
+
import { ForgotPasswordForm } from "@/components/auth/forgot-password-form";
|
|
5
|
+
|
|
6
|
+
export const metadata: Metadata = { title: "Forgot password" };
|
|
7
|
+
|
|
8
|
+
export default function ForgotPasswordPage() {
|
|
9
|
+
return (
|
|
10
|
+
<AuthCard
|
|
11
|
+
title="Forgot your password?"
|
|
12
|
+
description="Enter your email and we'll send you a link to reset it."
|
|
13
|
+
>
|
|
14
|
+
<ForgotPasswordForm />
|
|
15
|
+
</AuthCard>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import { Logo } from "@/components/logo";
|
|
4
|
+
import { ThemeToggle } from "@/components/theme-toggle";
|
|
5
|
+
|
|
6
|
+
export default function AuthLayout({ children }: { children: ReactNode }) {
|
|
7
|
+
return (
|
|
8
|
+
<div className="auth-shell">
|
|
9
|
+
<header className="site-header">
|
|
10
|
+
<Logo />
|
|
11
|
+
<ThemeToggle />
|
|
12
|
+
</header>
|
|
13
|
+
<main className="auth-main">
|
|
14
|
+
<div className="auth-column">{children}</div>
|
|
15
|
+
</main>
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -8,10 +8,8 @@ export const metadata: Metadata = { title: "Create account" };
|
|
|
8
8
|
|
|
9
9
|
export default function RegisterPage() {
|
|
10
10
|
return (
|
|
11
|
-
<AuthCard
|
|
12
|
-
|
|
13
|
-
description="The first account registered becomes the admin."
|
|
14
|
-
>
|
|
11
|
+
<AuthCard title="Create an account" description="The first account registered becomes the admin.">
|
|
12
|
+
{/* RegisterForm reads ?next= with useSearchParams, so it needs a Suspense boundary. */}
|
|
15
13
|
<Suspense fallback={<AuthFormSkeleton fields={4} />}>
|
|
16
14
|
<RegisterForm />
|
|
17
15
|
</Suspense>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
2
|
+
import { Suspense } from "react";
|
|
3
|
+
|
|
4
|
+
import { AuthCard, AuthFormSkeleton } from "@/components/auth/auth-card";
|
|
5
|
+
import { ResetPasswordForm } from "@/components/auth/reset-password-form";
|
|
6
|
+
|
|
7
|
+
export const metadata: Metadata = { title: "Reset password" };
|
|
8
|
+
|
|
9
|
+
export default function ResetPasswordPage() {
|
|
10
|
+
return (
|
|
11
|
+
<AuthCard title="Choose a new password" description="This signs you out on every other device.">
|
|
12
|
+
{/* The form reads ?token= with useSearchParams, so it needs a Suspense boundary. */}
|
|
13
|
+
<Suspense fallback={<AuthFormSkeleton fields={2} />}>
|
|
14
|
+
<ResetPasswordForm />
|
|
15
|
+
</Suspense>
|
|
16
|
+
</AuthCard>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ApiError,
|
|
5
|
+
// @feature rate-limit
|
|
6
|
+
enforceRateLimit,
|
|
7
|
+
// @end rate-limit
|
|
8
|
+
parseBody,
|
|
9
|
+
withAuth,
|
|
10
|
+
} from "@/lib/api";
|
|
11
|
+
import { hashPassword, setSessionCookie, verifyPassword } from "@/lib/auth";
|
|
12
|
+
import { connectDB } from "@/lib/db";
|
|
13
|
+
// @feature rate-limit
|
|
14
|
+
import { RATE_LIMITS } from "@/lib/rate-limit";
|
|
15
|
+
// @end rate-limit
|
|
16
|
+
import { changePasswordSchema } from "@/lib/validations/account";
|
|
17
|
+
import { User } from "@/models/user";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* POST /api/account/password { currentPassword, newPassword }
|
|
21
|
+
* Changes the password and signs out every other session.
|
|
22
|
+
*/
|
|
23
|
+
export const POST = withAuth(async (req, _ctx, user) => {
|
|
24
|
+
// @feature rate-limit
|
|
25
|
+
enforceRateLimit(`change-password:${user.id}`, RATE_LIMITS.sensitive);
|
|
26
|
+
// @end rate-limit
|
|
27
|
+
const { currentPassword, newPassword } = await parseBody(req, changePasswordSchema);
|
|
28
|
+
|
|
29
|
+
await connectDB();
|
|
30
|
+
const doc = await User.findById(user.id).select("+password").lean();
|
|
31
|
+
if (!doc || !(await verifyPassword(currentPassword, doc.password))) {
|
|
32
|
+
throw new ApiError(400, "Your current password is incorrect", "VALIDATION_ERROR", {
|
|
33
|
+
currentPassword: ["Your current password is incorrect"],
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const updated = await User.findByIdAndUpdate(
|
|
38
|
+
user.id,
|
|
39
|
+
{ password: await hashPassword(newPassword), $inc: { tokenVersion: 1 } },
|
|
40
|
+
{ returnDocument: "after" },
|
|
41
|
+
).lean();
|
|
42
|
+
// Keep this browser signed in with a token for the new version.
|
|
43
|
+
await setSessionCookie({ ...user, tokenVersion: updated?.tokenVersion ?? 0 });
|
|
44
|
+
return NextResponse.json({ ok: true });
|
|
45
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
|
|
3
|
+
import { parseBody, withAuth } from "@/lib/api";
|
|
4
|
+
import { setSessionCookie } from "@/lib/auth";
|
|
5
|
+
import { connectDB } from "@/lib/db";
|
|
6
|
+
import { toPublicUser } from "@/lib/users";
|
|
7
|
+
import { updateProfileSchema } from "@/lib/validations/account";
|
|
8
|
+
import { User } from "@/models/user";
|
|
9
|
+
|
|
10
|
+
/** PATCH /api/account { name }: update the signed-in user's profile. */
|
|
11
|
+
export const PATCH = withAuth(async (req, _ctx, user) => {
|
|
12
|
+
const { name } = await parseBody(req, updateProfileSchema);
|
|
13
|
+
await connectDB();
|
|
14
|
+
const updated = await User.findByIdAndUpdate(
|
|
15
|
+
user.id,
|
|
16
|
+
{ name },
|
|
17
|
+
{ returnDocument: "after", runValidators: true },
|
|
18
|
+
).lean();
|
|
19
|
+
if (!updated) throw new Error("Signed-in user disappeared");
|
|
20
|
+
|
|
21
|
+
const publicUser = toPublicUser(updated);
|
|
22
|
+
// The JWT carries the name, so re-issue it.
|
|
23
|
+
await setSessionCookie({ ...publicUser, tokenVersion: updated.tokenVersion ?? 0 });
|
|
24
|
+
return NextResponse.json({ user: publicUser });
|
|
25
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
|
|
3
|
+
import { withAuth } from "@/lib/api";
|
|
4
|
+
import { setSessionCookie } from "@/lib/auth";
|
|
5
|
+
import { bumpTokenVersion } from "@/lib/users";
|
|
6
|
+
|
|
7
|
+
/** DELETE /api/account/sessions: signs out every other device (this one stays signed in). */
|
|
8
|
+
export const DELETE = withAuth(async (_req, _ctx, user) => {
|
|
9
|
+
const tokenVersion = await bumpTokenVersion(user.id);
|
|
10
|
+
await setSessionCookie({ ...user, tokenVersion });
|
|
11
|
+
return NextResponse.json({ ok: true });
|
|
12
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
|
|
3
|
+
import { withAuth } from "@/lib/api";
|
|
4
|
+
import { listAuditEntries } from "@/lib/audit";
|
|
5
|
+
|
|
6
|
+
/** GET /api/admin/audit?limit=100 (requires audit:read) */
|
|
7
|
+
export const GET = withAuth(
|
|
8
|
+
async (req) => {
|
|
9
|
+
const limit = Math.min(500, Math.max(1, Number(req.nextUrl.searchParams.get("limit")) || 100));
|
|
10
|
+
return NextResponse.json({ entries: await listAuditEntries(limit) });
|
|
11
|
+
},
|
|
12
|
+
{ permission: "audit:read" },
|
|
13
|
+
);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { NextResponse } from "next/server";
|
|
2
2
|
|
|
3
3
|
import { ApiError, parseBody, withAuth } from "@/lib/api";
|
|
4
|
+
// @feature audit-log
|
|
5
|
+
import { recordAudit } from "@/lib/audit";
|
|
6
|
+
// @end audit-log
|
|
4
7
|
import { deleteUser, updateUserRole } from "@/lib/users";
|
|
5
8
|
import { updateRoleSchema } from "@/lib/validations/user";
|
|
6
9
|
|
|
@@ -16,16 +19,26 @@ export const PATCH = withAuth<Ctx>(
|
|
|
16
19
|
throw ApiError.badRequest("You can't change your own role", "CANNOT_MODIFY_SELF");
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
21
|
-
|
|
22
|
+
const result = await updateUserRole(id, role);
|
|
23
|
+
if (!result) throw ApiError.notFound("User not found");
|
|
24
|
+
// @feature audit-log
|
|
25
|
+
if (result.previousRole !== role) {
|
|
26
|
+
await recordAudit("user.role_changed", {
|
|
27
|
+
actor,
|
|
28
|
+
target: result.user,
|
|
29
|
+
details: { from: result.previousRole, to: role },
|
|
30
|
+
req,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
// @end audit-log
|
|
34
|
+
return NextResponse.json({ user: result.user });
|
|
22
35
|
},
|
|
23
36
|
{ permission: "users:update-role" },
|
|
24
37
|
);
|
|
25
38
|
|
|
26
39
|
/** DELETE /api/admin/users/:id (requires users:delete) */
|
|
27
40
|
export const DELETE = withAuth<Ctx>(
|
|
28
|
-
async (
|
|
41
|
+
async (req, ctx, actor) => {
|
|
29
42
|
const { id } = await ctx.params;
|
|
30
43
|
|
|
31
44
|
if (id === actor.id) {
|
|
@@ -34,6 +47,14 @@ export const DELETE = withAuth<Ctx>(
|
|
|
34
47
|
|
|
35
48
|
const deleted = await deleteUser(id);
|
|
36
49
|
if (!deleted) throw ApiError.notFound("User not found");
|
|
50
|
+
// @feature audit-log
|
|
51
|
+
await recordAudit("user.deleted", {
|
|
52
|
+
actor,
|
|
53
|
+
target: deleted,
|
|
54
|
+
details: { role: deleted.role },
|
|
55
|
+
req,
|
|
56
|
+
});
|
|
57
|
+
// @end audit-log
|
|
37
58
|
return NextResponse.json({ ok: true, id });
|
|
38
59
|
},
|
|
39
60
|
{ permission: "users:delete" },
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { after, NextResponse } from "next/server";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
apiHandler,
|
|
5
|
+
// @feature rate-limit
|
|
6
|
+
enforceRateLimit,
|
|
7
|
+
// @end rate-limit
|
|
8
|
+
parseBody,
|
|
9
|
+
} from "@/lib/api";
|
|
10
|
+
import { connectDB } from "@/lib/db";
|
|
11
|
+
// @feature rate-limit
|
|
12
|
+
import { getClientIp, RATE_LIMITS } from "@/lib/rate-limit";
|
|
13
|
+
// @end rate-limit
|
|
14
|
+
import { sendPasswordResetEmail } from "@/lib/tokens";
|
|
15
|
+
import { forgotPasswordSchema } from "@/lib/validations/auth";
|
|
16
|
+
import { User } from "@/models/user";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* POST /api/auth/forgot-password { email }
|
|
20
|
+
*
|
|
21
|
+
* Always answers with the same message, and does the lookup + email after
|
|
22
|
+
* the response is sent, so neither the body nor the timing reveals whether
|
|
23
|
+
* an account exists.
|
|
24
|
+
*/
|
|
25
|
+
export const POST = apiHandler(async (req) => {
|
|
26
|
+
// @feature rate-limit
|
|
27
|
+
enforceRateLimit(`forgot:${getClientIp(req)}`, RATE_LIMITS.passwordReset);
|
|
28
|
+
// @end rate-limit
|
|
29
|
+
const { email } = await parseBody(req, forgotPasswordSchema);
|
|
30
|
+
|
|
31
|
+
after(async () => {
|
|
32
|
+
try {
|
|
33
|
+
await connectDB();
|
|
34
|
+
const user = await User.findOne({ email }).lean();
|
|
35
|
+
if (user) {
|
|
36
|
+
await sendPasswordResetEmail({ id: String(user._id), name: user.name, email: user.email });
|
|
37
|
+
}
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error("[forgot-password] Failed to send reset email:", error);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return NextResponse.json({
|
|
44
|
+
ok: true,
|
|
45
|
+
message: "If an account exists for that email, we've sent a link to reset the password.",
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
import { NextResponse } from "next/server";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ApiError,
|
|
5
|
+
apiHandler,
|
|
6
|
+
// @feature rate-limit
|
|
7
|
+
enforceRateLimit,
|
|
8
|
+
// @end rate-limit
|
|
9
|
+
parseBody,
|
|
10
|
+
} from "@/lib/api";
|
|
4
11
|
import { setSessionCookie, verifyPassword } from "@/lib/auth";
|
|
5
12
|
import { connectDB } from "@/lib/db";
|
|
13
|
+
// @feature rate-limit
|
|
14
|
+
import { getClientIp, RATE_LIMITS } from "@/lib/rate-limit";
|
|
15
|
+
// @end rate-limit
|
|
6
16
|
import { toPublicUser } from "@/lib/users";
|
|
7
17
|
import { loginSchema } from "@/lib/validations/auth";
|
|
8
18
|
import { User } from "@/models/user";
|
|
9
19
|
|
|
10
20
|
export const POST = apiHandler(async (req) => {
|
|
21
|
+
// @feature rate-limit
|
|
22
|
+
enforceRateLimit(`login:${getClientIp(req)}`, RATE_LIMITS.login);
|
|
23
|
+
// @end rate-limit
|
|
11
24
|
const { email, password } = await parseBody(req, loginSchema);
|
|
25
|
+
// @feature rate-limit
|
|
26
|
+
// Also limit per account, so a distributed attack on one email is slowed down too.
|
|
27
|
+
enforceRateLimit(`login-email:${email}`, RATE_LIMITS.loginPerEmail);
|
|
28
|
+
// @end rate-limit
|
|
12
29
|
|
|
13
30
|
await connectDB();
|
|
14
31
|
const user = await User.findOne({ email }).select("+password").lean();
|
|
@@ -21,6 +38,6 @@ export const POST = apiHandler(async (req) => {
|
|
|
21
38
|
}
|
|
22
39
|
|
|
23
40
|
const publicUser = toPublicUser(user);
|
|
24
|
-
await setSessionCookie({
|
|
41
|
+
await setSessionCookie({ ...publicUser, tokenVersion: user.tokenVersion ?? 0 });
|
|
25
42
|
return NextResponse.json({ user: publicUser });
|
|
26
43
|
});
|
|
@@ -3,7 +3,7 @@ import { NextResponse } from "next/server";
|
|
|
3
3
|
import { getPermissions } from "@/config/rbac";
|
|
4
4
|
import { withAuth } from "@/lib/api";
|
|
5
5
|
import { setSessionCookie } from "@/lib/auth";
|
|
6
|
-
import { isSessionStale } from "@/lib/dal";
|
|
6
|
+
import { getSession, isSessionStale } from "@/lib/dal";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Returns the current user (from the DB) and their permissions. If the role
|
|
@@ -13,7 +13,9 @@ import { isSessionStale } from "@/lib/dal";
|
|
|
13
13
|
export const GET = withAuth(async (_req, _ctx, user) => {
|
|
14
14
|
const refreshed = await isSessionStale(user);
|
|
15
15
|
if (refreshed) {
|
|
16
|
-
|
|
16
|
+
// withAuth already verified the token version, so reuse it.
|
|
17
|
+
const session = await getSession();
|
|
18
|
+
await setSessionCookie({ ...user, tokenVersion: session?.ver ?? 0 });
|
|
17
19
|
}
|
|
18
20
|
return NextResponse.json({ user, permissions: getPermissions(user.role), refreshed });
|
|
19
21
|
});
|
|
@@ -1,16 +1,42 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
// @feature email
|
|
3
|
+
after,
|
|
4
|
+
// @end email
|
|
5
|
+
NextResponse,
|
|
6
|
+
} from "next/server";
|
|
2
7
|
|
|
3
8
|
import { DEFAULT_ROLE, FIRST_USER_ROLE } from "@/config/rbac";
|
|
4
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
ApiError,
|
|
11
|
+
apiHandler,
|
|
12
|
+
// @feature rate-limit
|
|
13
|
+
enforceRateLimit,
|
|
14
|
+
// @end rate-limit
|
|
15
|
+
parseBody,
|
|
16
|
+
} from "@/lib/api";
|
|
5
17
|
import { hashPassword, setSessionCookie } from "@/lib/auth";
|
|
6
18
|
import { connectDB } from "@/lib/db";
|
|
7
|
-
|
|
19
|
+
// @feature rate-limit
|
|
20
|
+
import { getClientIp, RATE_LIMITS } from "@/lib/rate-limit";
|
|
21
|
+
// @end rate-limit
|
|
22
|
+
// @feature email
|
|
23
|
+
import { sendVerificationEmail } from "@/lib/tokens";
|
|
24
|
+
// @end email
|
|
25
|
+
import {
|
|
26
|
+
claimFirstAdmin,
|
|
27
|
+
isDuplicateKeyError,
|
|
28
|
+
releaseFirstAdmin,
|
|
29
|
+
toPublicUser,
|
|
30
|
+
} from "@/lib/users";
|
|
8
31
|
import { registerSchema } from "@/lib/validations/auth";
|
|
9
32
|
import { User } from "@/models/user";
|
|
10
33
|
|
|
11
34
|
const EMAIL_TAKEN = "An account with this email already exists";
|
|
12
35
|
|
|
13
36
|
export const POST = apiHandler(async (req) => {
|
|
37
|
+
// @feature rate-limit
|
|
38
|
+
enforceRateLimit(`register:${getClientIp(req)}`, RATE_LIMITS.register);
|
|
39
|
+
// @end rate-limit
|
|
14
40
|
const { name, email, password } = await parseBody(req, registerSchema);
|
|
15
41
|
|
|
16
42
|
await connectDB();
|
|
@@ -35,6 +61,14 @@ export const POST = apiHandler(async (req) => {
|
|
|
35
61
|
}
|
|
36
62
|
|
|
37
63
|
const user = toPublicUser(created);
|
|
38
|
-
await setSessionCookie({
|
|
64
|
+
await setSessionCookie({ ...user, tokenVersion: created.tokenVersion ?? 0 });
|
|
65
|
+
// @feature email
|
|
66
|
+
// Send after the response so sign-up stays fast (and a mail outage can't break it).
|
|
67
|
+
after(() =>
|
|
68
|
+
sendVerificationEmail(user).catch((error) =>
|
|
69
|
+
console.error("[register] Failed to send verification email:", error),
|
|
70
|
+
),
|
|
71
|
+
);
|
|
72
|
+
// @end email
|
|
39
73
|
return NextResponse.json({ user }, { status: 201 });
|
|
40
74
|
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ApiError,
|
|
5
|
+
// @feature rate-limit
|
|
6
|
+
enforceRateLimit,
|
|
7
|
+
// @end rate-limit
|
|
8
|
+
withAuth,
|
|
9
|
+
} from "@/lib/api";
|
|
10
|
+
// @feature rate-limit
|
|
11
|
+
import { RATE_LIMITS } from "@/lib/rate-limit";
|
|
12
|
+
// @end rate-limit
|
|
13
|
+
import { sendVerificationEmail } from "@/lib/tokens";
|
|
14
|
+
|
|
15
|
+
/** POST /api/auth/resend-verification (signed in) */
|
|
16
|
+
export const POST = withAuth(async (_req, _ctx, user) => {
|
|
17
|
+
// @feature rate-limit
|
|
18
|
+
enforceRateLimit(`resend-verification:${user.id}`, RATE_LIMITS.sensitive);
|
|
19
|
+
// @end rate-limit
|
|
20
|
+
if (user.emailVerified) {
|
|
21
|
+
throw ApiError.badRequest("Your email is already verified", "ALREADY_VERIFIED");
|
|
22
|
+
}
|
|
23
|
+
await sendVerificationEmail(user);
|
|
24
|
+
return NextResponse.json({ ok: true });
|
|
25
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ApiError,
|
|
5
|
+
apiHandler,
|
|
6
|
+
// @feature rate-limit
|
|
7
|
+
enforceRateLimit,
|
|
8
|
+
// @end rate-limit
|
|
9
|
+
parseBody,
|
|
10
|
+
} from "@/lib/api";
|
|
11
|
+
import { hashPassword } from "@/lib/auth";
|
|
12
|
+
import { connectDB } from "@/lib/db";
|
|
13
|
+
// @feature rate-limit
|
|
14
|
+
import { getClientIp, RATE_LIMITS } from "@/lib/rate-limit";
|
|
15
|
+
// @end rate-limit
|
|
16
|
+
import { consumeToken } from "@/lib/tokens";
|
|
17
|
+
import { resetPasswordSchema } from "@/lib/validations/auth";
|
|
18
|
+
import { User } from "@/models/user";
|
|
19
|
+
|
|
20
|
+
/** POST /api/auth/reset-password { token, password } */
|
|
21
|
+
export const POST = apiHandler(async (req) => {
|
|
22
|
+
// @feature rate-limit
|
|
23
|
+
enforceRateLimit(`reset:${getClientIp(req)}`, RATE_LIMITS.passwordReset);
|
|
24
|
+
// @end rate-limit
|
|
25
|
+
const { token, password } = await parseBody(req, resetPasswordSchema);
|
|
26
|
+
|
|
27
|
+
const userId = await consumeToken(token, "password-reset");
|
|
28
|
+
if (!userId) {
|
|
29
|
+
throw ApiError.badRequest("This reset link is invalid or has expired", "INVALID_TOKEN");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await connectDB();
|
|
33
|
+
const updated = await User.findByIdAndUpdate(userId, {
|
|
34
|
+
password: await hashPassword(password),
|
|
35
|
+
// Sign out every existing session: whoever had the old password is out.
|
|
36
|
+
$inc: { tokenVersion: 1 },
|
|
37
|
+
});
|
|
38
|
+
if (!updated) throw ApiError.badRequest("This reset link is invalid or has expired", "INVALID_TOKEN");
|
|
39
|
+
// Clicking the emailed link proves the user owns the address.
|
|
40
|
+
await User.updateOne({ _id: userId, emailVerifiedAt: null }, { emailVerifiedAt: new Date() });
|
|
41
|
+
|
|
42
|
+
return NextResponse.json({ ok: true });
|
|
43
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { NextResponse, type NextRequest } from "next/server";
|
|
2
|
+
|
|
3
|
+
import { connectDB } from "@/lib/db";
|
|
4
|
+
import { consumeToken } from "@/lib/tokens";
|
|
5
|
+
import { User } from "@/models/user";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* GET /api/auth/verify-email?token=... (the link in the verification email)
|
|
9
|
+
* Marks the email as verified, then redirects to /verify-email?status=...
|
|
10
|
+
*/
|
|
11
|
+
export async function GET(request: NextRequest) {
|
|
12
|
+
const token = request.nextUrl.searchParams.get("token") ?? "";
|
|
13
|
+
const result = new URL("/verify-email", request.url);
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
const userId = await consumeToken(token, "email-verification");
|
|
17
|
+
if (userId) {
|
|
18
|
+
await connectDB();
|
|
19
|
+
await User.updateOne({ _id: userId, emailVerifiedAt: null }, { emailVerifiedAt: new Date() });
|
|
20
|
+
result.searchParams.set("status", "success");
|
|
21
|
+
} else {
|
|
22
|
+
result.searchParams.set("status", "invalid");
|
|
23
|
+
}
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error("[verify-email] Verification failed:", error);
|
|
26
|
+
result.searchParams.set("status", "error");
|
|
27
|
+
}
|
|
28
|
+
return NextResponse.redirect(result);
|
|
29
|
+
}
|
|
@@ -11,21 +11,19 @@ export const metadata: Metadata = { title: "Access denied" };
|
|
|
11
11
|
|
|
12
12
|
export default function ForbiddenPage() {
|
|
13
13
|
return (
|
|
14
|
-
<div className="
|
|
15
|
-
<header className="
|
|
14
|
+
<div className="status-page">
|
|
15
|
+
<header className="site-header">
|
|
16
16
|
<Logo />
|
|
17
17
|
</header>
|
|
18
|
-
<main className="
|
|
19
|
-
<div className="
|
|
20
|
-
<div className="
|
|
21
|
-
<ShieldAlert
|
|
18
|
+
<main className="status-page-main">
|
|
19
|
+
<div className="status-page-body">
|
|
20
|
+
<div className="status-icon status-icon--danger">
|
|
21
|
+
<ShieldAlert size={28} />
|
|
22
22
|
</div>
|
|
23
|
-
<div className="
|
|
24
|
-
<p className="
|
|
25
|
-
<h1 className="
|
|
26
|
-
|
|
27
|
-
</h1>
|
|
28
|
-
<p className="text-sm text-muted-foreground">
|
|
23
|
+
<div className="stack-sm">
|
|
24
|
+
<p className="status-code">403</p>
|
|
25
|
+
<h1 className="status-title">You don't have access to this page</h1>
|
|
26
|
+
<p className="muted text-sm">
|
|
29
27
|
Your role doesn't include the permission this page requires. If you think this is
|
|
30
28
|
a mistake, ask an admin to update your role.
|
|
31
29
|
</p>
|
|
@@ -34,7 +32,7 @@ export default function ForbiddenPage() {
|
|
|
34
32
|
<Suspense fallback={null}>
|
|
35
33
|
<SessionRefresher />
|
|
36
34
|
</Suspense>
|
|
37
|
-
<div className="
|
|
35
|
+
<div className="button-row">
|
|
38
36
|
<Button asChild>
|
|
39
37
|
<Link href="/dashboard">Go to dashboard</Link>
|
|
40
38
|
</Button>
|
|
@@ -4,9 +4,11 @@ import type { CSSProperties } from "react";
|
|
|
4
4
|
import { Toaster } from "sonner";
|
|
5
5
|
|
|
6
6
|
import { siteConfig } from "@/config/site";
|
|
7
|
+
import { appUrl } from "@/lib/env";
|
|
7
8
|
import { themeScript } from "@/lib/theme";
|
|
8
9
|
|
|
9
10
|
import "./globals.css";
|
|
11
|
+
import "@/styles/app.css";
|
|
10
12
|
|
|
11
13
|
const geistSans = Geist({
|
|
12
14
|
variable: "--font-geist-sans",
|
|
@@ -19,21 +21,22 @@ const geistMono = Geist_Mono({
|
|
|
19
21
|
});
|
|
20
22
|
|
|
21
23
|
export const metadata: Metadata = {
|
|
24
|
+
metadataBase: new URL(appUrl()),
|
|
22
25
|
title: { default: siteConfig.name, template: `%s · ${siteConfig.name}` },
|
|
23
26
|
description: siteConfig.description,
|
|
27
|
+
// @feature seo
|
|
28
|
+
openGraph: { type: "website", siteName: siteConfig.name },
|
|
29
|
+
twitter: { card: "summary_large_image" },
|
|
30
|
+
// @end seo
|
|
24
31
|
};
|
|
25
32
|
|
|
26
33
|
export default function RootLayout({ children }: LayoutProps<"/">) {
|
|
27
34
|
return (
|
|
28
|
-
<html
|
|
29
|
-
lang="en"
|
|
30
|
-
className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
|
|
31
|
-
suppressHydrationWarning
|
|
32
|
-
>
|
|
35
|
+
<html lang="en" className={`${geistSans.variable} ${geistMono.variable}`} suppressHydrationWarning>
|
|
33
36
|
<head>
|
|
34
37
|
<script dangerouslySetInnerHTML={{ __html: themeScript }} />
|
|
35
38
|
</head>
|
|
36
|
-
<body
|
|
39
|
+
<body>
|
|
37
40
|
{children}
|
|
38
41
|
<Toaster
|
|
39
42
|
position="top-right"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Link from "next/link";
|
|
2
|
+
|
|
3
|
+
import { Button } from "@/components/ui/button";
|
|
4
|
+
|
|
5
|
+
export default function NotFound() {
|
|
6
|
+
return (
|
|
7
|
+
<main className="status-page-main">
|
|
8
|
+
<div className="status-page-body">
|
|
9
|
+
<p className="status-code">404</p>
|
|
10
|
+
<h1 className="status-title">Page not found</h1>
|
|
11
|
+
<p className="muted text-sm">
|
|
12
|
+
The page you're looking for doesn't exist or has been moved.
|
|
13
|
+
</p>
|
|
14
|
+
<Button asChild>
|
|
15
|
+
<Link href="/">Back home</Link>
|
|
16
|
+
</Button>
|
|
17
|
+
</div>
|
|
18
|
+
</main>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ImageResponse } from "next/og";
|
|
2
|
+
|
|
3
|
+
import { siteConfig } from "@/config/site";
|
|
4
|
+
|
|
5
|
+
export const alt = siteConfig.name;
|
|
6
|
+
export const size = { width: 1200, height: 630 };
|
|
7
|
+
export const contentType = "image/png";
|
|
8
|
+
|
|
9
|
+
/** The image shown when a link to the site is shared (generated at build time). */
|
|
10
|
+
export default function OpengraphImage() {
|
|
11
|
+
return new ImageResponse(
|
|
12
|
+
<div
|
|
13
|
+
style={{
|
|
14
|
+
width: "100%",
|
|
15
|
+
height: "100%",
|
|
16
|
+
display: "flex",
|
|
17
|
+
flexDirection: "column",
|
|
18
|
+
justifyContent: "center",
|
|
19
|
+
padding: 80,
|
|
20
|
+
background: "linear-gradient(135deg, #0a0a0a 0%, #262626 100%)",
|
|
21
|
+
color: "#fafafa",
|
|
22
|
+
fontFamily: "sans-serif",
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
<div
|
|
26
|
+
style={{
|
|
27
|
+
width: 72,
|
|
28
|
+
height: 72,
|
|
29
|
+
borderRadius: 18,
|
|
30
|
+
background: "#fafafa",
|
|
31
|
+
color: "#0a0a0a",
|
|
32
|
+
display: "flex",
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
justifyContent: "center",
|
|
35
|
+
fontSize: 40,
|
|
36
|
+
fontWeight: 700,
|
|
37
|
+
marginBottom: 40,
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
{siteConfig.name.charAt(0)}
|
|
41
|
+
</div>
|
|
42
|
+
<div style={{ fontSize: 72, fontWeight: 700, lineHeight: 1.1 }}>{siteConfig.name}</div>
|
|
43
|
+
<div style={{ fontSize: 32, color: "#a3a3a3", marginTop: 24, maxWidth: 900 }}>
|
|
44
|
+
{siteConfig.description}
|
|
45
|
+
</div>
|
|
46
|
+
</div>,
|
|
47
|
+
size,
|
|
48
|
+
);
|
|
49
|
+
}
|