Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
9f32e9ef
Commit
9f32e9ef
authored
Jun 28, 2024
by
Sergey Mihaylin
Browse files
fix username claim
parent
0c3f9a16
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
backend/main.py
backend/main.py
+3
-3
No files found.
backend/main.py
View file @
9f32e9ef
...
...
@@ -1920,8 +1920,7 @@ async def oauth_callback(provider: str, request: Request, response: Response):
# If the user does not exist, check if signups are enabled
if
ENABLE_OAUTH_SIGNUP
.
value
:
# Check if an existing user with the same email already exists
email_claim
=
webui_app
.
state
.
config
.
OAUTH_USERNAME_CLAIM
existing_user
=
Users
.
get_user_by_email
(
user_data
.
get
(
email_claim
,
""
).
lower
())
existing_user
=
Users
.
get_user_by_email
(
user_data
.
get
(
"email"
,
""
).
lower
())
if
existing_user
:
raise
HTTPException
(
400
,
detail
=
ERROR_MESSAGES
.
EMAIL_TAKEN
)
...
...
@@ -1946,12 +1945,13 @@ async def oauth_callback(provider: str, request: Request, response: Response):
picture_url
=
""
if
not
picture_url
:
picture_url
=
"/user.png"
username_claim
=
webui_app
.
state
.
config
.
OAUTH_USERNAME_CLAIM
user
=
Auths
.
insert_new_auth
(
email
=
email
,
password
=
get_password_hash
(
str
(
uuid
.
uuid4
())
),
# Random password, not used
name
=
user_data
.
get
(
"name"
,
"User"
),
name
=
user_data
.
get
(
username_claim
,
"User"
),
profile_image_url
=
picture_url
,
role
=
webui_app
.
state
.
config
.
DEFAULT_USER_ROLE
,
oauth_sub
=
provider_sub
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment