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
8b13755d
Commit
8b13755d
authored
Jul 04, 2024
by
Timothy J. Baek
Browse files
Update auths.py
parent
8fe2a7bb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
38 deletions
+51
-38
backend/apps/webui/models/auths.py
backend/apps/webui/models/auths.py
+51
-38
No files found.
backend/apps/webui/models/auths.py
View file @
8b13755d
...
@@ -102,6 +102,8 @@ class AuthsTable:
...
@@ -102,6 +102,8 @@ class AuthsTable:
role
:
str
=
"pending"
,
role
:
str
=
"pending"
,
oauth_sub
:
Optional
[
str
]
=
None
,
oauth_sub
:
Optional
[
str
]
=
None
,
)
->
Optional
[
UserModel
]:
)
->
Optional
[
UserModel
]:
with
get_db
()
as
db
:
log
.
info
(
"insert_new_auth"
)
log
.
info
(
"insert_new_auth"
)
id
=
str
(
uuid
.
uuid4
())
id
=
str
(
uuid
.
uuid4
())
...
@@ -127,6 +129,8 @@ class AuthsTable:
...
@@ -127,6 +129,8 @@ class AuthsTable:
def
authenticate_user
(
self
,
email
:
str
,
password
:
str
)
->
Optional
[
UserModel
]:
def
authenticate_user
(
self
,
email
:
str
,
password
:
str
)
->
Optional
[
UserModel
]:
log
.
info
(
f
"authenticate_user:
{
email
}
"
)
log
.
info
(
f
"authenticate_user:
{
email
}
"
)
try
:
try
:
with
get_db
()
as
db
:
auth
=
db
.
query
(
Auth
).
filter_by
(
email
=
email
,
active
=
True
).
first
()
auth
=
db
.
query
(
Auth
).
filter_by
(
email
=
email
,
active
=
True
).
first
()
if
auth
:
if
auth
:
if
verify_password
(
password
,
auth
.
password
):
if
verify_password
(
password
,
auth
.
password
):
...
@@ -154,6 +158,7 @@ class AuthsTable:
...
@@ -154,6 +158,7 @@ class AuthsTable:
def
authenticate_user_by_trusted_header
(
self
,
email
:
str
)
->
Optional
[
UserModel
]:
def
authenticate_user_by_trusted_header
(
self
,
email
:
str
)
->
Optional
[
UserModel
]:
log
.
info
(
f
"authenticate_user_by_trusted_header:
{
email
}
"
)
log
.
info
(
f
"authenticate_user_by_trusted_header:
{
email
}
"
)
try
:
try
:
with
get_db
()
as
db
:
auth
=
db
.
query
(
Auth
).
filter
(
email
=
email
,
active
=
True
).
first
()
auth
=
db
.
query
(
Auth
).
filter
(
email
=
email
,
active
=
True
).
first
()
if
auth
:
if
auth
:
user
=
Users
.
get_user_by_id
(
auth
.
id
)
user
=
Users
.
get_user_by_id
(
auth
.
id
)
...
@@ -163,13 +168,19 @@ class AuthsTable:
...
@@ -163,13 +168,19 @@ class AuthsTable:
def
update_user_password_by_id
(
self
,
id
:
str
,
new_password
:
str
)
->
bool
:
def
update_user_password_by_id
(
self
,
id
:
str
,
new_password
:
str
)
->
bool
:
try
:
try
:
result
=
db
.
query
(
Auth
).
filter_by
(
id
=
id
).
update
({
"password"
:
new_password
})
with
get_db
()
as
db
:
result
=
(
db
.
query
(
Auth
).
filter_by
(
id
=
id
).
update
({
"password"
:
new_password
})
)
return
True
if
result
==
1
else
False
return
True
if
result
==
1
else
False
except
:
except
:
return
False
return
False
def
update_email_by_id
(
self
,
id
:
str
,
email
:
str
)
->
bool
:
def
update_email_by_id
(
self
,
id
:
str
,
email
:
str
)
->
bool
:
try
:
try
:
with
get_db
()
as
db
:
result
=
db
.
query
(
Auth
).
filter_by
(
id
=
id
).
update
({
"email"
:
email
})
result
=
db
.
query
(
Auth
).
filter_by
(
id
=
id
).
update
({
"email"
:
email
})
return
True
if
result
==
1
else
False
return
True
if
result
==
1
else
False
except
:
except
:
...
@@ -177,6 +188,8 @@ class AuthsTable:
...
@@ -177,6 +188,8 @@ class AuthsTable:
def
delete_auth_by_id
(
self
,
id
:
str
)
->
bool
:
def
delete_auth_by_id
(
self
,
id
:
str
)
->
bool
:
try
:
try
:
with
get_db
()
as
db
:
# Delete User
# Delete User
result
=
Users
.
delete_user_by_id
(
id
)
result
=
Users
.
delete_user_by_id
(
id
)
...
...
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