@commonpub/layer 0.8.5 → 0.8.6
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commonpub/layer",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./nuxt.config.ts",
|
|
6
6
|
"files": [
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
"vue-router": "^4.3.0",
|
|
55
55
|
"zod": "^4.3.6",
|
|
56
56
|
"@commonpub/auth": "0.5.1",
|
|
57
|
-
"@commonpub/editor": "0.7.9",
|
|
58
57
|
"@commonpub/docs": "0.6.2",
|
|
59
|
-
"@commonpub/protocol": "0.9.9",
|
|
60
58
|
"@commonpub/config": "0.9.1",
|
|
59
|
+
"@commonpub/editor": "0.7.9",
|
|
61
60
|
"@commonpub/learning": "0.5.0",
|
|
61
|
+
"@commonpub/protocol": "0.9.9",
|
|
62
62
|
"@commonpub/ui": "0.8.5"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { eq, and, isNull } from 'drizzle-orm';
|
|
2
|
+
import { users } from '@commonpub/schema';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
|
|
4
5
|
const signInSchema = z.object({
|
|
@@ -14,11 +15,21 @@ const signInSchema = z.object({
|
|
|
14
15
|
export default defineEventHandler(async (event) => {
|
|
15
16
|
const body = await parseBody(event, signInSchema);
|
|
16
17
|
|
|
17
|
-
let email
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
let email = body.identity;
|
|
19
|
+
|
|
20
|
+
// If identity doesn't look like an email, resolve username → email
|
|
21
|
+
if (!body.identity.includes('@')) {
|
|
22
|
+
const db = useDB();
|
|
23
|
+
const [user] = await db
|
|
24
|
+
.select({ email: users.email })
|
|
25
|
+
.from(users)
|
|
26
|
+
.where(and(eq(users.username, body.identity), isNull(users.deletedAt)))
|
|
27
|
+
.limit(1);
|
|
28
|
+
|
|
29
|
+
if (!user) {
|
|
30
|
+
throw createError({ statusCode: 401, statusMessage: 'Invalid credentials' });
|
|
31
|
+
}
|
|
32
|
+
email = user.email;
|
|
22
33
|
}
|
|
23
34
|
|
|
24
35
|
// Proxy to Better Auth's email sign-in (internal server-side call)
|