Rivet.Ident.User.Lib.Update (rivet_ident v3.5.0)
View SourceMaking changes to a user (administratively or as the user).
See UsersUpdate.update @spec for details on args. Explains for said args:
user_changes
map is variable, in that it's keys may vary based on the input args sent into GraphQL updatePerson() mutationcaller_authz
is the level of authorization for the caller, which changes what updates are allowed.target_user
is optional, if nil the user should be created, if exists then it's an update for that user
Example (create):
==> Rivet.Ident.UsersUpdate.update(%{
action: :upsert,
user: %{name: "The Doctor"},
email: %{email: "who@tardis.com"}
}, :admin)
{:ok, %User{}, %{"password": "R^EkW)aBY9G9", "passwordExp": 1649947803}}
Rivet.Ident.UsersUpdate.update(%{ action: :upsert, user: %{name: "The Doctor"}, email: %{email: "who@tardis.com"} }, :admin)
Example — update a user's name as the user
==> Rivet.Ident.UsersUpdate.update(%{
action: :upsert,
user: %{name: "Who"},
}, :user, %User{...})
{:ok, %User{}, %{}}
Example — remove a phone
==> Rivet.Ident.UsersUpdate.update(%{
action: :remove,
phone: %{id: "2342343-...-33"},
}, :user, %User{...})
{:ok, %User{}, %{}}
Summary
Functions
@spec update( user_changes :: map(), caller_authz :: :admin | :user, target_user :: Rivet.Ident.User.t() | nil ) :: {:ok, Rivet.Ident.User.t()} | {:error, reason :: String.t()}