Skip to content

Commit 5d91432

Browse files
committed
+changes
1 parent dea0f09 commit 5d91432

File tree

5 files changed

+63
-17
lines changed

5 files changed

+63
-17
lines changed

py/core/database/users.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,13 @@ async def get_user_by_email(self, email: str) -> User:
215215
)
216216

217217
async def create_user(
218-
self, email: str, password: str, is_superuser: bool = False
218+
self,
219+
email: str,
220+
password: str,
221+
is_superuser: bool = False,
222+
name: Optional[str] = None,
223+
bio: Optional[str] = None,
224+
profile_picture: Optional[str] = None
219225
) -> User:
220226
"""Create a new user."""
221227
try:
@@ -238,6 +244,9 @@ async def create_user(
238244
"id": generate_user_id(email),
239245
"is_superuser": is_superuser,
240246
"hashed_password": hashed_password,
247+
"name": name,
248+
"bio": bio,
249+
"profile_picture": profile_picture,
241250
"collection_ids": [],
242251
"limits_overrides": None,
243252
"metadata": None,
@@ -252,6 +261,9 @@ async def create_user(
252261
"is_verified",
253262
"created_at",
254263
"updated_at",
264+
"name",
265+
"bio",
266+
"profile_picture",
255267
"collection_ids",
256268
"limits_overrides",
257269
"metadata",
@@ -279,9 +291,9 @@ async def create_user(
279291
hashed_password=hashed_password,
280292
limits_overrides=json.loads(result["limits_overrides"] or "{}"),
281293
metadata=json.loads(result["metadata"] or "{}"),
282-
name=None,
283-
bio=None,
284-
profile_picture=None,
294+
name=result["name"],
295+
bio=result["bio"],
296+
profile_picture=result["profile_picture"],
285297
)
286298

287299
async def update_user(

py/core/main/api/v3/users_router.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,16 @@ def validate_password(password: str) -> bool:
129129
validate_password(password)
130130

131131
registration_response = await self.services.auth.register(
132-
email, password
132+
email, password,name,bio,profile_picture
133133
)
134-
if name or bio or profile_picture:
135-
return await self.services.auth.update_user(
136-
user_id=registration_response.id,
137-
name=name,
138-
bio=bio,
139-
profile_picture=profile_picture,
140-
)
134+
135+
# if name or bio or profile_picture:
136+
# return await self.services.auth.update_user(
137+
# user_id=registration_response.id,
138+
# name=name,
139+
# bio=bio,
140+
# profile_picture=profile_picture,
141+
# )
141142

142143
return registration_response
143144

py/core/main/services/auth_service.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,22 @@ def __init__(
3535
)
3636

3737
@telemetry_event("RegisterUser")
38-
async def register(self, email: str, password: str) -> User:
39-
return await self.providers.auth.register(email, password)
38+
async def register(
39+
self,
40+
email: str,
41+
password: str,
42+
name: Optional[str] = None,
43+
bio: Optional[str] = None,
44+
profile_picture: Optional[str] = None,
45+
) -> User:
46+
return await self.providers.auth.register(
47+
email=email,
48+
password=password,
49+
is_superuser=False,
50+
name=name,
51+
bio=bio,
52+
profile_picture=profile_picture
53+
)
4054

4155
@telemetry_event("SendVerificationEmail")
4256
async def send_verification_email(

py/core/providers/auth/r2r_auth.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,21 @@ def get_current_active_user(
196196
return current_user
197197

198198
async def register(
199-
self, email: str, password: str, is_superuser: bool = False
199+
self,
200+
email: str,
201+
password: str,
202+
is_superuser: bool = False,
203+
name: Optional[str] = None,
204+
bio: Optional[str] = None,
205+
profile_picture: Optional[str] = None
200206
) -> User:
201207
new_user = await self.database_provider.users_handler.create_user(
202-
email=email, password=password, is_superuser=is_superuser
208+
email=email,
209+
password=password,
210+
is_superuser=is_superuser,
211+
name=name,
212+
bio=bio,
213+
profile_picture=profile_picture
203214
)
204215
default_collection: CollectionResponse = (
205216
await self.database_provider.collections_handler.create_collection(

py/core/providers/auth/supabase.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,15 @@ async def decode_token(self, token: str) -> TokenData:
7272
"decode_token is not used with Supabase authentication"
7373
)
7474

75-
async def register(self, email: str, password: str) -> User: # type: ignore
75+
async def register(
76+
self,
77+
email: str,
78+
password: str,
79+
is_superuser: bool = False,
80+
name: Optional[str] = None,
81+
bio: Optional[str] = None,
82+
profile_picture: Optional[str] = None
83+
) -> User: # type: ignore
7684
# Use Supabase client to create a new user
7785

7886
if user := self.supabase.auth.sign_up(email=email, password=password):

0 commit comments

Comments
 (0)