vintasend 0.2.3 → 0.4.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 +227 -12
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/next.config.d.ts +1 -1
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/next.config.js +9 -4
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/forgot-password/forgot-password-notification-context.d.ts +6 -6
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/forgot-password/forgot-password-notification-context.js +16 -17
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/forgot-password/route.d.ts +7 -5
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/forgot-password/route.js +105 -79
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/login/route.d.ts +4 -5
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/login/route.js +96 -66
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/reset-password/route.d.ts +7 -5
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/reset-password/route.js +95 -71
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/signup/email-verification-notification-context.d.ts +6 -6
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/signup/email-verification-notification-context.js +18 -18
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/signup/route.d.ts +4 -5
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/signup/route.js +124 -96
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/verify-email/route.d.ts +7 -5
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/verify-email/route.js +94 -70
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/login/page.d.ts +1 -1
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/login/page.js +67 -55
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/reset-password/[token]/page.d.ts +1 -1
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/reset-password/[token]/page.js +76 -63
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/signup/page.d.ts +1 -1
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/signup/page.js +87 -63
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/verify-email/[token]/page.d.ts +1 -1
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/verify-email/[token]/page.js +50 -35
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/verify-email-sent/page.d.ts +1 -1
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/verify-email-sent/page.js +12 -12
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/layout.d.ts +7 -5
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/layout.js +15 -16
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/page.d.ts +1 -1
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/page.js +65 -21
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/AuthLayout.d.ts +7 -4
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/AuthLayout.js +7 -8
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/accordion.d.ts +18 -6
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/accordion.js +86 -48
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/alert-dialog.d.ts +58 -14
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/alert-dialog.js +135 -53
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/alert.d.ts +21 -7
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/alert.js +85 -49
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/avatar.d.ts +14 -5
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/avatar.js +77 -40
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/button.d.ts +25 -9
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/button.js +80 -58
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/card.d.ts +19 -7
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/card.js +98 -48
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/checkbox.d.ts +6 -3
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/checkbox.js +66 -42
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/collapsible.d.ts +10 -4
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/collapsible.js +48 -35
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/dialog.d.ts +40 -13
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/dialog.js +116 -50
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/dropdown-menu.d.ts +83 -19
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/dropdown-menu.js +170 -68
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/form.d.ts +53 -21
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/form.js +137 -83
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/input.d.ts +8 -2
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/input.js +60 -37
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/label.d.ts +10 -4
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/label.js +61 -40
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/menubar.d.ts +77 -23
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/menubar.js +188 -64
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/select.d.ts +48 -12
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/select.js +148 -66
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/textarea.d.ts +8 -2
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/textarea.js +59 -37
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/api-clients/auth.d.ts +10 -10
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/api-clients/auth.js +54 -55
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/api-clients/core.d.ts +14 -11
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/api-clients/core.js +1 -2
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/email.js +0 -1
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/logger.d.ts +3 -3
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/logger.js +9 -10
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/schemas/auth.d.ts +66 -32
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/schemas/auth.js +74 -54
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/auth.js +7 -8
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/notifications-with-queue.d.ts +14 -4
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/notifications-with-queue.js +14 -10
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/notifications.d.ts +11 -7
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/notifications.js +39 -26
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/temporal-queue-service.d.ts +11 -8
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/temporal-queue-service.js +14 -15
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/temporal.d.ts +1 -1
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/temporal.js +9 -10
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/utils.d.ts +1 -1
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/utils.js +4 -5
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/activities.d.ts +6 -5
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/activities.js +14 -14
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/config.d.ts +1 -1
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/config.js +2 -3
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/constants.d.ts +1 -1
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/constants.js +1 -2
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/worker.js +20 -22
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/workflows.d.ts +3 -2
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/workflows.js +10 -9
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/tailwind.config.d.ts +74 -74
- package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/tailwind.config.js +80 -81
- package/dist/implementations/vintasend-nodemailer/src/index.js +6 -4
- package/dist/implementations/vintasend-nodemailer/src/nodemailer-notification-adapter.d.ts +36 -14
- package/dist/implementations/vintasend-nodemailer/src/nodemailer-notification-adapter.js +26 -28
- package/dist/implementations/vintasend-prisma/src/index.js +6 -4
- package/dist/implementations/vintasend-prisma/src/prisma-notification-backend.d.ts +232 -138
- package/dist/implementations/vintasend-prisma/src/prisma-notification-backend.js +275 -262
- package/dist/implementations/vintasend-pug/src/index.js +6 -4
- package/dist/implementations/vintasend-pug/src/pug-email-template-renderer.d.ts +18 -7
- package/dist/implementations/vintasend-pug/src/pug-email-template-renderer.js +19 -21
- package/dist/implementations/vintasend-winston/src/index.js +6 -4
- package/dist/implementations/vintasend-winston/src/winston-logger.d.ts +6 -6
- package/dist/implementations/vintasend-winston/src/winston-logger.js +65 -50
- package/dist/index.d.ts +13 -5
- package/dist/index.js +13 -1
- package/dist/services/attachment-manager/base-attachment-manager.d.ts +42 -0
- package/dist/services/attachment-manager/base-attachment-manager.js +115 -0
- package/dist/services/attachment-manager/local-file-attachment-manager.d.ts +58 -0
- package/dist/services/attachment-manager/local-file-attachment-manager.js +192 -0
- package/dist/services/notification-adapters/base-notification-adapter.d.ts +36 -4
- package/dist/services/notification-adapters/base-notification-adapter.js +73 -4
- package/dist/services/notification-backends/base-notification-backend.d.ts +54 -11
- package/dist/services/notification-backends/base-notification-backend.js +12 -0
- package/dist/services/notification-context-generators-map.d.ts +1 -1
- package/dist/services/notification-context-registry.d.ts +14 -9
- package/dist/services/notification-context-registry.js +30 -31
- package/dist/services/notification-queue-service/base-notification-queue-service.d.ts +1 -1
- package/dist/services/notification-service.d.ts +73 -13
- package/dist/services/notification-service.js +125 -8
- package/dist/services/notification-template-renderers/base-email-template-renderer.d.ts +3 -3
- package/dist/services/notification-template-renderers/base-notification-template-renderer.d.ts +2 -2
- package/dist/types/attachment.d.ts +42 -0
- package/dist/types/attachment.js +7 -0
- package/dist/types/notification-type-config.d.ts +2 -2
- package/dist/types/notification.d.ts +21 -0
- package/dist/types/one-off-notification.d.ts +72 -0
- package/dist/types/one-off-notification.js +2 -0
- package/package.json +13 -11
|
@@ -1,73 +1,103 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
var __createBinding =
|
|
2
|
+
(this && this.__createBinding) ||
|
|
3
|
+
(Object.create
|
|
4
|
+
? (o, m, k, k2) => {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: () => m[k] };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}
|
|
12
|
+
: (o, m, k, k2) => {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
});
|
|
16
|
+
var __setModuleDefault =
|
|
17
|
+
(this && this.__setModuleDefault) ||
|
|
18
|
+
(Object.create
|
|
19
|
+
? (o, v) => {
|
|
20
|
+
Object.defineProperty(o, 'default', { enumerable: true, value: v });
|
|
21
|
+
}
|
|
22
|
+
: (o, v) => {
|
|
23
|
+
o['default'] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar =
|
|
26
|
+
(this && this.__importStar) ||
|
|
27
|
+
(() => {
|
|
28
|
+
var ownKeys = (o) => {
|
|
29
|
+
ownKeys =
|
|
30
|
+
Object.getOwnPropertyNames ||
|
|
31
|
+
((o) => {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
});
|
|
36
|
+
return ownKeys(o);
|
|
26
37
|
};
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
return (mod) => {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null)
|
|
42
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
43
|
+
if (k[i] !== 'default') __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
33
46
|
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports,
|
|
47
|
+
})();
|
|
48
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
36
49
|
exports.POST = POST;
|
|
37
|
-
const client_1 = require(
|
|
38
|
-
const auth_1 = require(
|
|
39
|
-
const auth_2 = require(
|
|
40
|
-
const server_1 = require(
|
|
41
|
-
const z = __importStar(require(
|
|
42
|
-
const library_1 = require(
|
|
50
|
+
const client_1 = require('@prisma/client');
|
|
51
|
+
const auth_1 = require('../../../../lib/services/auth');
|
|
52
|
+
const auth_2 = require('../../../../lib/schemas/auth');
|
|
53
|
+
const server_1 = require('next/server');
|
|
54
|
+
const z = __importStar(require('zod'));
|
|
55
|
+
const library_1 = require('@prisma/client/runtime/library');
|
|
43
56
|
async function POST(req) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return server_1.NextResponse.json({ success: false, error: 'Invalid credentials' }, { status: 401 });
|
|
55
|
-
}
|
|
56
|
-
if (!user.isEmailVerified) {
|
|
57
|
-
return server_1.NextResponse.json({ success: false, error: 'Please verify your email first' }, { status: 403 });
|
|
58
|
-
}
|
|
59
|
-
const token = (0, auth_1.generateToken)({ userId: user.id });
|
|
60
|
-
return server_1.NextResponse.json({ success: true, data: { token } });
|
|
57
|
+
try {
|
|
58
|
+
const body = await req.json();
|
|
59
|
+
const prisma = new client_1.PrismaClient();
|
|
60
|
+
const { email, password } = auth_2.loginSchema.parse(body);
|
|
61
|
+
const user = await prisma.user.findUnique({ where: { email } });
|
|
62
|
+
if (!user) {
|
|
63
|
+
return server_1.NextResponse.json(
|
|
64
|
+
{ success: false, error: 'Invalid credentials' },
|
|
65
|
+
{ status: 401 },
|
|
66
|
+
);
|
|
61
67
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
const isValid = await (0, auth_1.verifyPassword)(password, user.password);
|
|
69
|
+
if (!isValid) {
|
|
70
|
+
return server_1.NextResponse.json(
|
|
71
|
+
{ success: false, error: 'Invalid credentials' },
|
|
72
|
+
{ status: 401 },
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
if (!user.isEmailVerified) {
|
|
76
|
+
return server_1.NextResponse.json(
|
|
77
|
+
{ success: false, error: 'Please verify your email first' },
|
|
78
|
+
{ status: 403 },
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
const token = (0, auth_1.generateToken)({ userId: user.id });
|
|
82
|
+
return server_1.NextResponse.json({ success: true, data: { token } });
|
|
83
|
+
} catch (error) {
|
|
84
|
+
if (error instanceof z.ZodError) {
|
|
85
|
+
const validationError = error;
|
|
86
|
+
return server_1.NextResponse.json(
|
|
87
|
+
{ success: false, error: 'Validation error', details: validationError.flatten() },
|
|
88
|
+
{ status: 400 },
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
if (error instanceof library_1.PrismaClientKnownRequestError) {
|
|
92
|
+
return server_1.NextResponse.json(
|
|
93
|
+
{ success: false, error: 'Database error occurred' },
|
|
94
|
+
{ status: 500 },
|
|
95
|
+
);
|
|
72
96
|
}
|
|
97
|
+
console.error('Signup error:', error);
|
|
98
|
+
return server_1.NextResponse.json(
|
|
99
|
+
{ success: false, error: 'Internal server error' },
|
|
100
|
+
{ status: 500 },
|
|
101
|
+
);
|
|
102
|
+
}
|
|
73
103
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { NextResponse } from 'next/server';
|
|
2
|
-
import
|
|
1
|
+
import type { NextResponse } from 'next/server';
|
|
2
|
+
import type * as z from 'zod';
|
|
3
3
|
import type { WriteApiResponse } from '../../../../lib/api-clients/core';
|
|
4
|
-
import
|
|
4
|
+
import type { PasswordResetValues } from '../../../../lib/schemas/auth';
|
|
5
5
|
type PasswordResetSuccess = null;
|
|
6
6
|
type PasswordResetValidationError = z.typeToFlattenedError<PasswordResetValues>;
|
|
7
|
-
export type PasswordResetApiResponse = WriteApiResponse<
|
|
7
|
+
export type PasswordResetApiResponse = WriteApiResponse<
|
|
8
|
+
PasswordResetSuccess,
|
|
9
|
+
PasswordResetValidationError
|
|
10
|
+
>;
|
|
8
11
|
type PasswordResetNextResponse = NextResponse<PasswordResetApiResponse>;
|
|
9
12
|
export declare function POST(req: Request): Promise<PasswordResetNextResponse>;
|
|
10
|
-
export {};
|
package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/reset-password/route.js
CHANGED
|
@@ -1,78 +1,102 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
var __createBinding =
|
|
2
|
+
(this && this.__createBinding) ||
|
|
3
|
+
(Object.create
|
|
4
|
+
? (o, m, k, k2) => {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: () => m[k] };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}
|
|
12
|
+
: (o, m, k, k2) => {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
});
|
|
16
|
+
var __setModuleDefault =
|
|
17
|
+
(this && this.__setModuleDefault) ||
|
|
18
|
+
(Object.create
|
|
19
|
+
? (o, v) => {
|
|
20
|
+
Object.defineProperty(o, 'default', { enumerable: true, value: v });
|
|
21
|
+
}
|
|
22
|
+
: (o, v) => {
|
|
23
|
+
o['default'] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar =
|
|
26
|
+
(this && this.__importStar) ||
|
|
27
|
+
(() => {
|
|
28
|
+
var ownKeys = (o) => {
|
|
29
|
+
ownKeys =
|
|
30
|
+
Object.getOwnPropertyNames ||
|
|
31
|
+
((o) => {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
});
|
|
36
|
+
return ownKeys(o);
|
|
26
37
|
};
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
return (mod) => {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null)
|
|
42
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
43
|
+
if (k[i] !== 'default') __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
33
46
|
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports,
|
|
47
|
+
})();
|
|
48
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
36
49
|
exports.POST = POST;
|
|
37
|
-
const client_1 = require(
|
|
38
|
-
const auth_1 = require(
|
|
39
|
-
const server_1 = require(
|
|
40
|
-
const auth_2 = require(
|
|
41
|
-
const z = __importStar(require(
|
|
42
|
-
const library_1 = require(
|
|
50
|
+
const client_1 = require('@prisma/client');
|
|
51
|
+
const auth_1 = require('../../../../lib/services/auth');
|
|
52
|
+
const server_1 = require('next/server');
|
|
53
|
+
const auth_2 = require('../../../../lib/schemas/auth');
|
|
54
|
+
const z = __importStar(require('zod'));
|
|
55
|
+
const library_1 = require('@prisma/client/runtime/library');
|
|
43
56
|
async function POST(req) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
where: { id: Number.parseInt(decoded.userId) },
|
|
62
|
-
data: { password: hashedPassword },
|
|
63
|
-
});
|
|
64
|
-
await prisma.token.delete({ where: { id: tokenRecord.id } });
|
|
65
|
-
return server_1.NextResponse.json({ success: true, message: 'Password updated successfully' });
|
|
57
|
+
try {
|
|
58
|
+
const body = await req.json();
|
|
59
|
+
const { token, password } = auth_2.passwordResetSchema.parse(body);
|
|
60
|
+
const decoded = (0, auth_1.verifyToken)(token);
|
|
61
|
+
const prisma = new client_1.PrismaClient();
|
|
62
|
+
const tokenRecord = await prisma.token.findFirst({
|
|
63
|
+
where: {
|
|
64
|
+
token,
|
|
65
|
+
type: 'PASSWORD_RESET',
|
|
66
|
+
expiresAt: { gt: new Date() },
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
if (!tokenRecord) {
|
|
70
|
+
return server_1.NextResponse.json(
|
|
71
|
+
{ success: false, error: 'Invalid or expired token' },
|
|
72
|
+
{ status: 400 },
|
|
73
|
+
);
|
|
66
74
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
const hashedPassword = await (0, auth_1.hashPassword)(password);
|
|
76
|
+
await prisma.user.update({
|
|
77
|
+
where: { id: Number.parseInt(decoded.userId) },
|
|
78
|
+
data: { password: hashedPassword },
|
|
79
|
+
});
|
|
80
|
+
await prisma.token.delete({ where: { id: tokenRecord.id } });
|
|
81
|
+
return server_1.NextResponse.json({ success: true, message: 'Password updated successfully' });
|
|
82
|
+
} catch (error) {
|
|
83
|
+
if (error instanceof z.ZodError) {
|
|
84
|
+
const validationError = error;
|
|
85
|
+
return server_1.NextResponse.json(
|
|
86
|
+
{ success: false, error: 'Validation error', details: validationError.flatten() },
|
|
87
|
+
{ status: 400 },
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
if (error instanceof library_1.PrismaClientKnownRequestError) {
|
|
91
|
+
return server_1.NextResponse.json(
|
|
92
|
+
{ success: false, error: 'Database error occurred' },
|
|
93
|
+
{ status: 500 },
|
|
94
|
+
);
|
|
77
95
|
}
|
|
96
|
+
console.error('Password reset error:', error);
|
|
97
|
+
return server_1.NextResponse.json(
|
|
98
|
+
{ success: false, error: 'Internal server error' },
|
|
99
|
+
{ status: 500 },
|
|
100
|
+
);
|
|
101
|
+
}
|
|
78
102
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ContextGenerator } from 'vintasend/src/services/notification-context-registry';
|
|
2
2
|
export declare class EmailVerificationNotificationContextGenerator implements ContextGenerator {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
generate(params: {
|
|
4
|
+
token: string;
|
|
5
|
+
}): Promise<{
|
|
6
|
+
firstName: string | null;
|
|
7
|
+
verificationLink: string;
|
|
8
|
+
}>;
|
|
9
9
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
2
|
exports.EmailVerificationNotificationContextGenerator = void 0;
|
|
4
|
-
const client_1 = require(
|
|
3
|
+
const client_1 = require('@prisma/client');
|
|
5
4
|
class EmailVerificationNotificationContextGenerator {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
return {
|
|
17
|
-
firstName: token.user.firstName,
|
|
18
|
-
verificationLink: `${APP_DOMAIN}/auth/verify-email/${params.token}/`,
|
|
19
|
-
};
|
|
5
|
+
async generate(params) {
|
|
6
|
+
const prisma = new client_1.PrismaClient();
|
|
7
|
+
const APP_DOMAIN = process.env.APP_DOMAIN;
|
|
8
|
+
const token = await prisma.token.findUnique({
|
|
9
|
+
where: { token: params.token },
|
|
10
|
+
select: { user: true },
|
|
11
|
+
});
|
|
12
|
+
if (!token || !token.user) {
|
|
13
|
+
throw new Error('Token not found');
|
|
20
14
|
}
|
|
15
|
+
return {
|
|
16
|
+
firstName: token.user.firstName,
|
|
17
|
+
verificationLink: `${APP_DOMAIN}/auth/verify-email/${params.token}/`,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
21
20
|
}
|
|
22
|
-
exports.EmailVerificationNotificationContextGenerator =
|
|
21
|
+
exports.EmailVerificationNotificationContextGenerator =
|
|
22
|
+
EmailVerificationNotificationContextGenerator;
|
package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/signup/route.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { NextResponse } from 'next/server';
|
|
2
|
+
import type * as z from 'zod';
|
|
3
3
|
import type { WriteApiResponse } from '../../../../lib/api-clients/core';
|
|
4
|
-
import
|
|
4
|
+
import type { SignupValues } from '../../../../lib/schemas/auth';
|
|
5
5
|
type SignupSuccess = {
|
|
6
|
-
|
|
6
|
+
message: string;
|
|
7
7
|
};
|
|
8
8
|
type SignupValidationError = z.typeToFlattenedError<SignupValues>;
|
|
9
9
|
export type SignupApiResponse = WriteApiResponse<SignupSuccess, SignupValidationError>;
|
|
10
10
|
type SignupNextResponse = NextResponse<SignupApiResponse>;
|
|
11
11
|
export declare function POST(req: Request): Promise<SignupNextResponse>;
|
|
12
|
-
export {};
|