@xk2800/nextjs-template 0.7.2-beta.1 → 0.7.2-beta.3
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/api/feedback.js +13 -0
- package/dist/api/feedback.js.map +1 -1
- package/dist/api/feedback.mjs +1 -1
- package/dist/api/marketing.js +13 -0
- package/dist/api/marketing.js.map +1 -1
- package/dist/api/marketing.mjs +2 -2
- package/dist/auth/helpers.js +13 -0
- package/dist/auth/helpers.js.map +1 -1
- package/dist/auth/helpers.mjs +2 -2
- package/dist/auth/index.d.mts +18 -0
- package/dist/auth/index.d.ts +18 -0
- package/dist/auth/index.js +13 -0
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/index.mjs +1 -1
- package/dist/{chunk-EIS4SCQW.mjs → chunk-ONJDPUVO.mjs} +15 -2
- package/dist/chunk-ONJDPUVO.mjs.map +1 -0
- package/dist/{chunk-H3XZTZ5K.mjs → chunk-YHQ4A5RF.mjs} +3 -3
- package/dist/{chunk-H3XZTZ5K.mjs.map → chunk-YHQ4A5RF.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/chunk-EIS4SCQW.mjs.map +0 -1
package/dist/auth/helpers.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { getCurrentSession, hasRole, normalizeCallbackUrl, requireAuth, requireRole } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { getCurrentSession, hasRole, normalizeCallbackUrl, requireAuth, requireRole } from '../chunk-YHQ4A5RF.mjs';
|
|
2
|
+
import '../chunk-ONJDPUVO.mjs';
|
|
3
3
|
import '../chunk-O5EQYHNC.mjs';
|
|
4
4
|
import '../chunk-6OAHCEDJ.mjs';
|
|
5
5
|
import '../chunk-2BJ3B4FR.mjs';
|
package/dist/auth/index.d.mts
CHANGED
|
@@ -82,6 +82,15 @@ declare function createAuth(overrides?: AuthOverrides): better_auth.Auth<{
|
|
|
82
82
|
};
|
|
83
83
|
emailVerification: {
|
|
84
84
|
autoSignInAfterVerification: true;
|
|
85
|
+
afterEmailVerification(user: {
|
|
86
|
+
id: string;
|
|
87
|
+
createdAt: Date;
|
|
88
|
+
updatedAt: Date;
|
|
89
|
+
email: string;
|
|
90
|
+
emailVerified: boolean;
|
|
91
|
+
name: string;
|
|
92
|
+
image?: string | null | undefined;
|
|
93
|
+
}): Promise<void>;
|
|
85
94
|
sendVerificationEmail({ user, url }: {
|
|
86
95
|
user: better_auth.User;
|
|
87
96
|
url: string;
|
|
@@ -2410,6 +2419,15 @@ declare const auth: better_auth.Auth<{
|
|
|
2410
2419
|
};
|
|
2411
2420
|
emailVerification: {
|
|
2412
2421
|
autoSignInAfterVerification: true;
|
|
2422
|
+
afterEmailVerification(user: {
|
|
2423
|
+
id: string;
|
|
2424
|
+
createdAt: Date;
|
|
2425
|
+
updatedAt: Date;
|
|
2426
|
+
email: string;
|
|
2427
|
+
emailVerified: boolean;
|
|
2428
|
+
name: string;
|
|
2429
|
+
image?: string | null | undefined;
|
|
2430
|
+
}): Promise<void>;
|
|
2413
2431
|
sendVerificationEmail({ user, url }: {
|
|
2414
2432
|
user: better_auth.User;
|
|
2415
2433
|
url: string;
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -82,6 +82,15 @@ declare function createAuth(overrides?: AuthOverrides): better_auth.Auth<{
|
|
|
82
82
|
};
|
|
83
83
|
emailVerification: {
|
|
84
84
|
autoSignInAfterVerification: true;
|
|
85
|
+
afterEmailVerification(user: {
|
|
86
|
+
id: string;
|
|
87
|
+
createdAt: Date;
|
|
88
|
+
updatedAt: Date;
|
|
89
|
+
email: string;
|
|
90
|
+
emailVerified: boolean;
|
|
91
|
+
name: string;
|
|
92
|
+
image?: string | null | undefined;
|
|
93
|
+
}): Promise<void>;
|
|
85
94
|
sendVerificationEmail({ user, url }: {
|
|
86
95
|
user: better_auth.User;
|
|
87
96
|
url: string;
|
|
@@ -2410,6 +2419,15 @@ declare const auth: better_auth.Auth<{
|
|
|
2410
2419
|
};
|
|
2411
2420
|
emailVerification: {
|
|
2412
2421
|
autoSignInAfterVerification: true;
|
|
2422
|
+
afterEmailVerification(user: {
|
|
2423
|
+
id: string;
|
|
2424
|
+
createdAt: Date;
|
|
2425
|
+
updatedAt: Date;
|
|
2426
|
+
email: string;
|
|
2427
|
+
emailVerified: boolean;
|
|
2428
|
+
name: string;
|
|
2429
|
+
image?: string | null | undefined;
|
|
2430
|
+
}): Promise<void>;
|
|
2413
2431
|
sendVerificationEmail({ user, url }: {
|
|
2414
2432
|
user: better_auth.User;
|
|
2415
2433
|
url: string;
|
package/dist/auth/index.js
CHANGED
|
@@ -1236,6 +1236,15 @@ async function packageSessionCreated(log, ...[session, context]) {
|
|
|
1236
1236
|
console.error("Failed to log login activity", error);
|
|
1237
1237
|
}
|
|
1238
1238
|
}
|
|
1239
|
+
async function promoteFirstAdmin(user) {
|
|
1240
|
+
var _a;
|
|
1241
|
+
const adminEmail = (_a = process.env.ADMIN_EMAIL) == null ? void 0 : _a.trim().toLowerCase();
|
|
1242
|
+
if (!adminEmail || !user.emailVerified || user.email.toLowerCase() !== adminEmail) return;
|
|
1243
|
+
const [existing] = await db.select({ id: users.id }).from(users).where(drizzleOrm.eq(users.role, "admin")).limit(1);
|
|
1244
|
+
if (existing) return;
|
|
1245
|
+
await db.update(users).set({ role: "admin" }).where(drizzleOrm.eq(users.id, user.id));
|
|
1246
|
+
user.role = "admin";
|
|
1247
|
+
}
|
|
1239
1248
|
function createAuth(overrides = {}) {
|
|
1240
1249
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1241
1250
|
const socialProviders = __spreadValues(__spreadValues({}, config.AUTH_ENABLE_GOOGLE ? {
|
|
@@ -1315,6 +1324,9 @@ function createAuth(overrides = {}) {
|
|
|
1315
1324
|
// callback that flips users.emailVerified on click.
|
|
1316
1325
|
emailVerification: {
|
|
1317
1326
|
autoSignInAfterVerification: true,
|
|
1327
|
+
async afterEmailVerification(user) {
|
|
1328
|
+
await promoteFirstAdmin(user);
|
|
1329
|
+
},
|
|
1318
1330
|
async sendVerificationEmail({ user, url }) {
|
|
1319
1331
|
const { EmailTemplateVerifyEmail: EmailTemplateVerifyEmail2 } = await Promise.resolve().then(() => (init_email_template_verify_email(), email_template_verify_email_exports));
|
|
1320
1332
|
await (await getResend()).emails.send({
|
|
@@ -1358,6 +1370,7 @@ function createAuth(overrides = {}) {
|
|
|
1358
1370
|
create: {
|
|
1359
1371
|
async after(user, context) {
|
|
1360
1372
|
var _a2, _b2, _c2, _d2;
|
|
1373
|
+
await promoteFirstAdmin(user);
|
|
1361
1374
|
await ((_d2 = (_c2 = (_b2 = (_a2 = overrides.databaseHooks) == null ? void 0 : _a2.user) == null ? void 0 : _b2.create) == null ? void 0 : _c2.after) == null ? void 0 : _d2.call(_c2, user, context));
|
|
1362
1375
|
}
|
|
1363
1376
|
}
|