mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 18:42:34 +01:00
fix(auth): match OIDC users by their sub claim so an email change still logs in
Store the provider's `sub` on a new nullable users.oidc_sub column, look users up by it first and fall back to email, backfilling the sub on the next login. A user matched by sub gets their stored email updated, unless another account already holds it. Fixes #1690 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
de0eff320c
commit
9d4bb40a6d
@@ -64,6 +64,14 @@ class DBUsersHandler(DBBaseHandler):
|
||||
query = self.filter(select(User), emails=[email])
|
||||
return session.scalar(query.limit(1))
|
||||
|
||||
@begin_session
|
||||
def get_user_by_oidc_sub(
|
||||
self,
|
||||
oidc_sub: str,
|
||||
session: Session = INJECTED_SESSION,
|
||||
) -> User | None:
|
||||
return session.scalar(select(User).filter_by(oidc_sub=oidc_sub).limit(1))
|
||||
|
||||
@begin_session
|
||||
def get_user(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user