Skip to content

Commit

Permalink
[identity] add email to user metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
patatoid committed Jan 24, 2025
1 parent 5ec1e58 commit f146899
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/boruta_identity/lib/boruta_identity/resource_owners.ex
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,16 @@ defmodule BorutaIdentity.ResourceOwners do
end

@spec metadata(user :: User.t(), scope :: String.t()) :: metadata :: map()
def metadata(%User{metadata: %{} = metadata}, _scope) when metadata == %{}, do: %{}
def metadata(%User{username: username, metadata: %{} = metadata}, _scope) when metadata == %{}, do: %{
"email" => username
}

def metadata(user, scope) do
user.metadata
|> User.metadata_filter(user.backend)
|> metadata_scope_filter(scope, user.backend)
|> Enum.into(%{})
|> Map.put("email", user.username)
end

defp merge_claims(
Expand Down

0 comments on commit f146899

Please sign in to comment.