feat: support email scope to retrieve oidc info
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
3d4020cf27
commit
613a5f2643
1 changed files with 8 additions and 3 deletions
|
|
@ -185,7 +185,9 @@ defmodule Mv.Accounts.User do
|
||||||
oidc_user_info = Ash.Changeset.get_argument(changeset, :oidc_user_info)
|
oidc_user_info = Ash.Changeset.get_argument(changeset, :oidc_user_info)
|
||||||
|
|
||||||
# Get the new email from OIDC user_info
|
# Get the new email from OIDC user_info
|
||||||
new_email = Map.get(oidc_user_info, "preferred_username")
|
# Support both "email" (standard OIDC) and "preferred_username" (Rauthy)
|
||||||
|
new_email =
|
||||||
|
Map.get(oidc_user_info, "email") || Map.get(oidc_user_info, "preferred_username")
|
||||||
|
|
||||||
changeset
|
changeset
|
||||||
|> Ash.Changeset.change_attribute(:oidc_id, oidc_id)
|
|> Ash.Changeset.change_attribute(:oidc_id, oidc_id)
|
||||||
|
|
@ -239,8 +241,11 @@ defmodule Mv.Accounts.User do
|
||||||
change fn changeset, _ctx ->
|
change fn changeset, _ctx ->
|
||||||
user_info = Ash.Changeset.get_argument(changeset, :user_info)
|
user_info = Ash.Changeset.get_argument(changeset, :user_info)
|
||||||
|
|
||||||
|
# Support both "email" (standard OIDC like Authentik, Keycloak) and "preferred_username" (Rauthy)
|
||||||
|
email = user_info["email"] || user_info["preferred_username"]
|
||||||
|
|
||||||
changeset
|
changeset
|
||||||
|> Ash.Changeset.change_attribute(:email, user_info["preferred_username"])
|
|> Ash.Changeset.change_attribute(:email, email)
|
||||||
|> Ash.Changeset.change_attribute(:oidc_id, user_info["sub"] || user_info["id"])
|
|> Ash.Changeset.change_attribute(:oidc_id, user_info["sub"] || user_info["id"])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue