zitejs 0.9.78 → 0.9.79
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/cjs/auth/index.d.ts
CHANGED
|
@@ -250,11 +250,11 @@ export declare function logout(opts?: {
|
|
|
250
250
|
export type User = {
|
|
251
251
|
id: string;
|
|
252
252
|
name: string;
|
|
253
|
+
firstName?: string;
|
|
254
|
+
lastName?: string;
|
|
253
255
|
email: string;
|
|
254
256
|
emailVerified: boolean;
|
|
255
257
|
image?: string | null;
|
|
256
|
-
firstName?: string;
|
|
257
|
-
lastName?: string;
|
|
258
258
|
createdAt: Date;
|
|
259
259
|
updatedAt: Date;
|
|
260
260
|
};
|
|
@@ -2,8 +2,8 @@ export interface ZiteAuthUser {
|
|
|
2
2
|
id: string;
|
|
3
3
|
email: string;
|
|
4
4
|
name: string;
|
|
5
|
-
firstName
|
|
6
|
-
lastName
|
|
5
|
+
firstName: string;
|
|
6
|
+
lastName: string;
|
|
7
7
|
}
|
|
8
8
|
import type { ZiteAuthMethods } from '../auth/index.js';
|
|
9
9
|
export type { ZiteAuthMethods };
|
|
@@ -34,7 +34,7 @@ export declare function ziteAuth(config?: ZiteAuthConfig): import("better-auth")
|
|
|
34
34
|
max: number;
|
|
35
35
|
};
|
|
36
36
|
emailAndPassword: {
|
|
37
|
-
enabled:
|
|
37
|
+
enabled: true;
|
|
38
38
|
};
|
|
39
39
|
plugins: {
|
|
40
40
|
id: "generic-oauth";
|
|
@@ -223,7 +223,7 @@ export declare function ziteAuth(config?: ZiteAuthConfig): import("better-auth")
|
|
|
223
223
|
databaseHooks: {
|
|
224
224
|
user: {
|
|
225
225
|
create: {
|
|
226
|
-
before: (
|
|
226
|
+
before: (user: {
|
|
227
227
|
id: string;
|
|
228
228
|
createdAt: Date;
|
|
229
229
|
updatedAt: Date;
|
|
@@ -231,7 +231,19 @@ export declare function ziteAuth(config?: ZiteAuthConfig): import("better-auth")
|
|
|
231
231
|
emailVerified: boolean;
|
|
232
232
|
name: string;
|
|
233
233
|
image?: string | null | undefined;
|
|
234
|
-
} & Record<string, unknown>) => Promise<
|
|
234
|
+
} & Record<string, unknown>) => Promise<{
|
|
235
|
+
data: {
|
|
236
|
+
firstName: string;
|
|
237
|
+
lastName: string;
|
|
238
|
+
id: string;
|
|
239
|
+
createdAt: Date;
|
|
240
|
+
updatedAt: Date;
|
|
241
|
+
email: string;
|
|
242
|
+
emailVerified: boolean;
|
|
243
|
+
name: string;
|
|
244
|
+
image?: string | null | undefined;
|
|
245
|
+
};
|
|
246
|
+
} | undefined>;
|
|
235
247
|
after: ((user: {
|
|
236
248
|
id: string;
|
|
237
249
|
createdAt: Date;
|
|
@@ -58,7 +58,7 @@ function ziteAuth(config = {}) {
|
|
|
58
58
|
baseURL: 'http://localhost',
|
|
59
59
|
advanced: { disableCSRFCheck: true },
|
|
60
60
|
rateLimit: { window: 60, max: 10 },
|
|
61
|
-
emailAndPassword: { enabled:
|
|
61
|
+
emailAndPassword: { enabled: true },
|
|
62
62
|
plugins,
|
|
63
63
|
user: {
|
|
64
64
|
modelName: 'zite_user',
|
|
@@ -73,23 +73,35 @@ function ziteAuth(config = {}) {
|
|
|
73
73
|
databaseHooks: {
|
|
74
74
|
user: {
|
|
75
75
|
create: {
|
|
76
|
-
before:
|
|
77
|
-
|
|
76
|
+
before: async (user) => {
|
|
77
|
+
if (domainCheckHook) {
|
|
78
78
|
const allowed = await domainCheckHook(user.email);
|
|
79
79
|
if (!allowed) {
|
|
80
80
|
throw new Error('Signup not allowed for this email');
|
|
81
81
|
}
|
|
82
|
-
return undefined;
|
|
83
82
|
}
|
|
84
|
-
|
|
83
|
+
const u = user;
|
|
84
|
+
if (user.name && !u.firstName && !u.lastName) {
|
|
85
|
+
const parts = user.name.split(' ');
|
|
86
|
+
return {
|
|
87
|
+
data: {
|
|
88
|
+
...user,
|
|
89
|
+
firstName: parts[0] || '',
|
|
90
|
+
lastName: parts.slice(1).join(' ') || '',
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return undefined;
|
|
95
|
+
},
|
|
85
96
|
after: config.onSignup
|
|
86
97
|
? async (user) => {
|
|
98
|
+
const u = user;
|
|
87
99
|
await config.onSignup({
|
|
88
100
|
id: user.id,
|
|
89
101
|
email: user.email,
|
|
90
102
|
name: user.name,
|
|
91
|
-
firstName:
|
|
92
|
-
lastName:
|
|
103
|
+
firstName: u.firstName || '',
|
|
104
|
+
lastName: u.lastName || '',
|
|
93
105
|
});
|
|
94
106
|
}
|
|
95
107
|
: undefined,
|
|
@@ -103,6 +115,8 @@ function ziteAuth(config = {}) {
|
|
|
103
115
|
id: session.userId,
|
|
104
116
|
email: '',
|
|
105
117
|
name: '',
|
|
118
|
+
firstName: '',
|
|
119
|
+
lastName: '',
|
|
106
120
|
});
|
|
107
121
|
}
|
|
108
122
|
: undefined,
|
package/dist/esm/auth/index.d.ts
CHANGED
|
@@ -250,11 +250,11 @@ export declare function logout(opts?: {
|
|
|
250
250
|
export type User = {
|
|
251
251
|
id: string;
|
|
252
252
|
name: string;
|
|
253
|
+
firstName?: string;
|
|
254
|
+
lastName?: string;
|
|
253
255
|
email: string;
|
|
254
256
|
emailVerified: boolean;
|
|
255
257
|
image?: string | null;
|
|
256
|
-
firstName?: string;
|
|
257
|
-
lastName?: string;
|
|
258
258
|
createdAt: Date;
|
|
259
259
|
updatedAt: Date;
|
|
260
260
|
};
|
|
@@ -2,8 +2,8 @@ export interface ZiteAuthUser {
|
|
|
2
2
|
id: string;
|
|
3
3
|
email: string;
|
|
4
4
|
name: string;
|
|
5
|
-
firstName
|
|
6
|
-
lastName
|
|
5
|
+
firstName: string;
|
|
6
|
+
lastName: string;
|
|
7
7
|
}
|
|
8
8
|
import type { ZiteAuthMethods } from '../auth/index.js';
|
|
9
9
|
export type { ZiteAuthMethods };
|
|
@@ -34,7 +34,7 @@ export declare function ziteAuth(config?: ZiteAuthConfig): import("better-auth")
|
|
|
34
34
|
max: number;
|
|
35
35
|
};
|
|
36
36
|
emailAndPassword: {
|
|
37
|
-
enabled:
|
|
37
|
+
enabled: true;
|
|
38
38
|
};
|
|
39
39
|
plugins: {
|
|
40
40
|
id: "generic-oauth";
|
|
@@ -223,7 +223,7 @@ export declare function ziteAuth(config?: ZiteAuthConfig): import("better-auth")
|
|
|
223
223
|
databaseHooks: {
|
|
224
224
|
user: {
|
|
225
225
|
create: {
|
|
226
|
-
before: (
|
|
226
|
+
before: (user: {
|
|
227
227
|
id: string;
|
|
228
228
|
createdAt: Date;
|
|
229
229
|
updatedAt: Date;
|
|
@@ -231,7 +231,19 @@ export declare function ziteAuth(config?: ZiteAuthConfig): import("better-auth")
|
|
|
231
231
|
emailVerified: boolean;
|
|
232
232
|
name: string;
|
|
233
233
|
image?: string | null | undefined;
|
|
234
|
-
} & Record<string, unknown>) => Promise<
|
|
234
|
+
} & Record<string, unknown>) => Promise<{
|
|
235
|
+
data: {
|
|
236
|
+
firstName: string;
|
|
237
|
+
lastName: string;
|
|
238
|
+
id: string;
|
|
239
|
+
createdAt: Date;
|
|
240
|
+
updatedAt: Date;
|
|
241
|
+
email: string;
|
|
242
|
+
emailVerified: boolean;
|
|
243
|
+
name: string;
|
|
244
|
+
image?: string | null | undefined;
|
|
245
|
+
};
|
|
246
|
+
} | undefined>;
|
|
235
247
|
after: ((user: {
|
|
236
248
|
id: string;
|
|
237
249
|
createdAt: Date;
|
|
@@ -55,7 +55,7 @@ export function ziteAuth(config = {}) {
|
|
|
55
55
|
baseURL: 'http://localhost',
|
|
56
56
|
advanced: { disableCSRFCheck: true },
|
|
57
57
|
rateLimit: { window: 60, max: 10 },
|
|
58
|
-
emailAndPassword: { enabled:
|
|
58
|
+
emailAndPassword: { enabled: true },
|
|
59
59
|
plugins,
|
|
60
60
|
user: {
|
|
61
61
|
modelName: 'zite_user',
|
|
@@ -70,23 +70,35 @@ export function ziteAuth(config = {}) {
|
|
|
70
70
|
databaseHooks: {
|
|
71
71
|
user: {
|
|
72
72
|
create: {
|
|
73
|
-
before:
|
|
74
|
-
|
|
73
|
+
before: async (user) => {
|
|
74
|
+
if (domainCheckHook) {
|
|
75
75
|
const allowed = await domainCheckHook(user.email);
|
|
76
76
|
if (!allowed) {
|
|
77
77
|
throw new Error('Signup not allowed for this email');
|
|
78
78
|
}
|
|
79
|
-
return undefined;
|
|
80
79
|
}
|
|
81
|
-
|
|
80
|
+
const u = user;
|
|
81
|
+
if (user.name && !u.firstName && !u.lastName) {
|
|
82
|
+
const parts = user.name.split(' ');
|
|
83
|
+
return {
|
|
84
|
+
data: {
|
|
85
|
+
...user,
|
|
86
|
+
firstName: parts[0] || '',
|
|
87
|
+
lastName: parts.slice(1).join(' ') || '',
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
},
|
|
82
93
|
after: config.onSignup
|
|
83
94
|
? async (user) => {
|
|
95
|
+
const u = user;
|
|
84
96
|
await config.onSignup({
|
|
85
97
|
id: user.id,
|
|
86
98
|
email: user.email,
|
|
87
99
|
name: user.name,
|
|
88
|
-
firstName:
|
|
89
|
-
lastName:
|
|
100
|
+
firstName: u.firstName || '',
|
|
101
|
+
lastName: u.lastName || '',
|
|
90
102
|
});
|
|
91
103
|
}
|
|
92
104
|
: undefined,
|
|
@@ -100,6 +112,8 @@ export function ziteAuth(config = {}) {
|
|
|
100
112
|
id: session.userId,
|
|
101
113
|
email: '',
|
|
102
114
|
name: '',
|
|
115
|
+
firstName: '',
|
|
116
|
+
lastName: '',
|
|
103
117
|
});
|
|
104
118
|
}
|
|
105
119
|
: undefined,
|