@lobehub/lobehub 2.0.0-next.154 โ 2.0.0-next.155
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/CHANGELOG.md +25 -0
- package/changelog/v1.json +9 -0
- package/package.json +1 -1
- package/packages/python-interpreter/src/types.ts +2 -2
- package/src/auth.ts +21 -0
- package/src/server/services/user/index.ts +35 -22
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
## [Version 2.0.0-next.155](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.154...v2.0.0-next.155)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2025-12-03**</sup>
|
|
8
|
+
|
|
9
|
+
#### ๐ Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **misc**: Missing init user after user creation.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **misc**: Missing init user after user creation, closes [#10587](https://github.com/lobehub/lobe-chat/issues/10587) ([0e97a42](https://github.com/lobehub/lobe-chat/commit/0e97a42))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
## [Version 2.0.0-next.154](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.153...v2.0.0-next.154)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2025-12-03**</sup>
|
package/changelog/v1.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/lobehub",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.155",
|
|
4
4
|
"description": "LobeHub - an open-source,comprehensive AI Agent framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -4,9 +4,9 @@ export interface PythonOptions {
|
|
|
4
4
|
*/
|
|
5
5
|
pyodideIndexUrl?: string;
|
|
6
6
|
/**
|
|
7
|
-
* PyPI
|
|
7
|
+
* PyPI index URL, must support [JSON API](https://warehouse.pypa.io/api-reference/json.html)
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* Default value: `https://pypi.org/pypi/{package_name}/json`
|
|
10
10
|
*/
|
|
11
11
|
pypiIndexUrl?: string;
|
|
12
12
|
}
|
package/src/auth.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import { initBetterAuthSSOProviders } from '@/libs/better-auth/sso';
|
|
14
14
|
import { parseSSOProviders } from '@/libs/better-auth/utils/server';
|
|
15
15
|
import { EmailService } from '@/server/services/email';
|
|
16
|
+
import { UserService } from '@/server/services/user';
|
|
16
17
|
|
|
17
18
|
// Email verification link expiration time (in seconds)
|
|
18
19
|
// Default is 1 hour (3600 seconds) as per Better Auth documentation
|
|
@@ -120,6 +121,26 @@ export const auth = betterAuth({
|
|
|
120
121
|
database: drizzleAdapter(serverDB, {
|
|
121
122
|
provider: 'pg',
|
|
122
123
|
}),
|
|
124
|
+
/**
|
|
125
|
+
* Run user bootstrap for every newly created account (email, magic link, OAuth/social, etc.).
|
|
126
|
+
* Using Better Auth database hooks ensures we catch social flows that bypass /sign-up/* routes.
|
|
127
|
+
* Ref: https://www.better-auth.com/docs/reference/options#databasehooks
|
|
128
|
+
*/
|
|
129
|
+
databaseHooks: {
|
|
130
|
+
user: {
|
|
131
|
+
create: {
|
|
132
|
+
after: async (user) => {
|
|
133
|
+
const userService = new UserService(serverDB);
|
|
134
|
+
await userService.initUser({
|
|
135
|
+
email: user.email,
|
|
136
|
+
id: user.id,
|
|
137
|
+
username: user.username as string | null,
|
|
138
|
+
// TODO: if add phone plugin, we should fill phone here
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
123
144
|
user: {
|
|
124
145
|
additionalFields: {
|
|
125
146
|
username: {
|
|
@@ -8,6 +8,15 @@ import { KeyVaultsGateKeeper } from '@/server/modules/KeyVaultsEncrypt';
|
|
|
8
8
|
import { S3 } from '@/server/modules/S3';
|
|
9
9
|
import { AgentService } from '@/server/services/agent';
|
|
10
10
|
|
|
11
|
+
type CreatedUser = {
|
|
12
|
+
email?: string | null;
|
|
13
|
+
firstName?: string | null;
|
|
14
|
+
id: string;
|
|
15
|
+
lastName?: string | null;
|
|
16
|
+
phone?: string | null;
|
|
17
|
+
username?: string | null;
|
|
18
|
+
};
|
|
19
|
+
|
|
11
20
|
export class UserService {
|
|
12
21
|
private db: LobeChatDatabase;
|
|
13
22
|
|
|
@@ -15,6 +24,30 @@ export class UserService {
|
|
|
15
24
|
this.db = db;
|
|
16
25
|
}
|
|
17
26
|
|
|
27
|
+
async initUser(user: CreatedUser) {
|
|
28
|
+
const agentService = new AgentService(this.db, user.id);
|
|
29
|
+
await agentService.createInbox();
|
|
30
|
+
|
|
31
|
+
/* โ cloud slot โ */
|
|
32
|
+
/* โ cloud slot โ */
|
|
33
|
+
|
|
34
|
+
const analytics = await initializeServerAnalytics();
|
|
35
|
+
analytics?.identify(user.id, {
|
|
36
|
+
email: user.email ?? undefined,
|
|
37
|
+
firstName: user.firstName ?? undefined,
|
|
38
|
+
lastName: user.lastName ?? undefined,
|
|
39
|
+
phone: user.phone ?? undefined,
|
|
40
|
+
username: user.username ?? undefined,
|
|
41
|
+
});
|
|
42
|
+
analytics?.track({
|
|
43
|
+
name: 'user_register_completed',
|
|
44
|
+
properties: {
|
|
45
|
+
spm: 'user_service.init_user.user_created',
|
|
46
|
+
},
|
|
47
|
+
userId: user.id,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
18
51
|
createUser = async (id: string, params: UserJSON) => {
|
|
19
52
|
// Check if user already exists
|
|
20
53
|
const res = await UserModel.findById(this.db, id);
|
|
@@ -34,10 +67,6 @@ export class UserService {
|
|
|
34
67
|
return index === 0;
|
|
35
68
|
});
|
|
36
69
|
|
|
37
|
-
/* โ cloud slot โ */
|
|
38
|
-
|
|
39
|
-
/* โ cloud slot โ */
|
|
40
|
-
|
|
41
70
|
// 2. create user in database
|
|
42
71
|
await UserModel.createUser(this.db, {
|
|
43
72
|
avatar: params.image_url,
|
|
@@ -50,30 +79,14 @@ export class UserService {
|
|
|
50
79
|
username: params.username,
|
|
51
80
|
});
|
|
52
81
|
|
|
53
|
-
|
|
54
|
-
const agentService = new AgentService(this.db, id);
|
|
55
|
-
await agentService.createInbox();
|
|
56
|
-
|
|
57
|
-
/* โ cloud slot โ */
|
|
58
|
-
|
|
59
|
-
/* โ cloud slot โ */
|
|
60
|
-
|
|
61
|
-
//analytics
|
|
62
|
-
const analytics = await initializeServerAnalytics();
|
|
63
|
-
analytics?.identify(id, {
|
|
82
|
+
await this.initUser({
|
|
64
83
|
email: email?.email_address,
|
|
65
84
|
firstName: params.first_name,
|
|
85
|
+
id,
|
|
66
86
|
lastName: params.last_name,
|
|
67
87
|
phone: phone?.phone_number,
|
|
68
88
|
username: params.username,
|
|
69
89
|
});
|
|
70
|
-
analytics?.track({
|
|
71
|
-
name: 'user_register_completed',
|
|
72
|
-
properties: {
|
|
73
|
-
spm: 'user_service.create_user.user_created',
|
|
74
|
-
},
|
|
75
|
-
userId: id,
|
|
76
|
-
});
|
|
77
90
|
|
|
78
91
|
return { message: 'user created', success: true };
|
|
79
92
|
};
|