always assign default roles on login

successful authentication of a user always grants 'user' role

rather than only on first user creation in db
This commit is contained in:
Min RK
2021-12-16 12:42:47 +01:00
parent 92c6a23a13
commit 2a8428dbb0
2 changed files with 6 additions and 4 deletions

View File

@@ -771,8 +771,9 @@ class BaseHandler(RequestHandler):
# Only set `admin` if the authenticator returned an explicit value.
if admin is not None and admin != user.admin:
user.admin = admin
roles.assign_default_roles(self.db, entity=user)
self.db.commit()
# always ensure default roles ('user', 'admin' if admin) are assigned
# after a successful login
roles.assign_default_roles(self.db, entity=user)
# always set auth_state and commit,
# because there could be key-rotation or clearing of previous values
# going on.