fix(auth): refresh the user record on successful auth

This will ensure the state of `request.user` is good to go
for any other users which obtain it after the backend.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-12-09 23:01:45 -08:00
parent d0e183a738
commit c47578f158
No known key found for this signature in database
GPG key ID: F7E46DED420788F3

View file

@ -122,6 +122,7 @@ class BasicAuthBackend(AuthenticationBackend):
# exists, due to ForeignKey constraints in the schema upheld # exists, due to ForeignKey constraints in the schema upheld
# by mysqlclient. # by mysqlclient.
user = db.query(User).filter(User.ID == record.UsersID).first() user = db.query(User).filter(User.ID == record.UsersID).first()
db.refresh(user)
user.nonce = util.make_nonce() user.nonce = util.make_nonce()
user.authenticated = True user.authenticated = True