@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/api/marketing.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { unexpectedErrorMessage } from '../chunk-653GF7OT.mjs';
|
|
2
2
|
import { MARKETING_SEGMENT_ID, setSubscribed } from '../chunk-NQELV53D.mjs';
|
|
3
|
-
import { hasRole } from '../chunk-
|
|
4
|
-
import { auth } from '../chunk-
|
|
3
|
+
import { hasRole } from '../chunk-YHQ4A5RF.mjs';
|
|
4
|
+
import { auth } from '../chunk-ONJDPUVO.mjs';
|
|
5
5
|
import '../chunk-O5EQYHNC.mjs';
|
|
6
6
|
import '../chunk-6OAHCEDJ.mjs';
|
|
7
7
|
import '../chunk-2BJ3B4FR.mjs';
|
package/dist/auth/helpers.js
CHANGED
|
@@ -1239,6 +1239,15 @@ async function packageSessionCreated(log, ...[session, context]) {
|
|
|
1239
1239
|
console.error("Failed to log login activity", error);
|
|
1240
1240
|
}
|
|
1241
1241
|
}
|
|
1242
|
+
async function promoteFirstAdmin(user) {
|
|
1243
|
+
var _a;
|
|
1244
|
+
const adminEmail = (_a = process.env.ADMIN_EMAIL) == null ? void 0 : _a.trim().toLowerCase();
|
|
1245
|
+
if (!adminEmail || !user.emailVerified || user.email.toLowerCase() !== adminEmail) return;
|
|
1246
|
+
const [existing] = await db.select({ id: users.id }).from(users).where(drizzleOrm.eq(users.role, "admin")).limit(1);
|
|
1247
|
+
if (existing) return;
|
|
1248
|
+
await db.update(users).set({ role: "admin" }).where(drizzleOrm.eq(users.id, user.id));
|
|
1249
|
+
user.role = "admin";
|
|
1250
|
+
}
|
|
1242
1251
|
function createAuth(overrides = {}) {
|
|
1243
1252
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1244
1253
|
const socialProviders = __spreadValues(__spreadValues({}, config.AUTH_ENABLE_GOOGLE ? {
|
|
@@ -1318,6 +1327,9 @@ function createAuth(overrides = {}) {
|
|
|
1318
1327
|
// callback that flips users.emailVerified on click.
|
|
1319
1328
|
emailVerification: {
|
|
1320
1329
|
autoSignInAfterVerification: true,
|
|
1330
|
+
async afterEmailVerification(user) {
|
|
1331
|
+
await promoteFirstAdmin(user);
|
|
1332
|
+
},
|
|
1321
1333
|
async sendVerificationEmail({ user, url }) {
|
|
1322
1334
|
const { EmailTemplateVerifyEmail: EmailTemplateVerifyEmail2 } = await Promise.resolve().then(() => (init_email_template_verify_email(), email_template_verify_email_exports));
|
|
1323
1335
|
await (await getResend()).emails.send({
|
|
@@ -1361,6 +1373,7 @@ function createAuth(overrides = {}) {
|
|
|
1361
1373
|
create: {
|
|
1362
1374
|
async after(user, context) {
|
|
1363
1375
|
var _a2, _b2, _c2, _d2;
|
|
1376
|
+
await promoteFirstAdmin(user);
|
|
1364
1377
|
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));
|
|
1365
1378
|
}
|
|
1366
1379
|
}
|