AuthShield v0.0.1 AuthShield.Resources.Users View Source
Users are the base identity in our architecture. It is used to authenticate an profile or to authorize an action given its set of roles.
We use an Role-based access control architecture as an approach to restricting system access to authorized users, so our resources contains users, roles and permissions.
This module implements an interface to deal with database transactions as inserts, updates, deletes, etc.
Link to this section Summary
Functions
Changes an set of AuthShield.Resources.Schemas.Role
of the AuthShield.Resources.Schemas.User
.
Changes an set of AuthShield.Resources.Schemas.Role
of the AuthShield.Resources.Schemas.User
.
Deletes a User
register.
Deletes a AuthShield.Resources.Schemas.User
register.
Gets a AuthShield.Resources.Schemas.User
register by its filters.
Gets a AuthShield.Resources.Schemas.User
register by its filters.
Creates a new AuthShield.Resources.Schemas.User
register.
Creates a new AuthShield.Resources.Schemas.User
register.
Returns a list of AuthShield.Resources.Schemas.User
by its filters
Preloads the user data by the given fields.
Changes a User
status.
Changes a AuthShield.Resources.Schemas.User
status.
Updates a AuthShield.Resources.Schemas.User
register.
Updates a AuthShield.Resources.Schemas.User
register.
Link to this section Types
Transactional responses of failed
success_response()
View Sourcesuccess_response() :: {:ok, AuthShield.Resources.Schemas.User.t()}
Transactional responses of success
Link to this section Functions
change_roles(user, roles)
View Sourcechange_roles( user :: AuthShield.Resources.Schemas.User.t(), roles :: [AuthShield.Resources.Schemas.Role.t()] ) :: success_response() | failed_response()
Changes an set of AuthShield.Resources.Schemas.Role
of the AuthShield.Resources.Schemas.User
.
It will add or remove roles from the list, so you should pass the complete list every time you use this function.
Roles are used in AuthShield.Authorization
requests.
Exemples:
AuthShield.Resources.Users.change_roles(user, roles)
change_roles!(user, roles)
View Sourcechange_roles!( user :: AuthShield.Resources.Schemas.User.t(), roles :: [AuthShield.Resources.Schemas.Role.t()] ) :: AuthShield.Resources.Schemas.User.t() | no_return()
Changes an set of AuthShield.Resources.Schemas.Role
of the AuthShield.Resources.Schemas.User
.
Similar to append_role/2
but returns the struct or raises if the changeset is invalid.
delete(user)
View Sourcedelete(user :: AuthShield.Resources.Schemas.User.t()) :: success_response() | failed_response()
Deletes a User
register.
Exemples:
AuthShield.Resources.Users.delete(user)
delete!(user)
View Sourcedelete!(user :: AuthShield.Resources.Schemas.User.t()) :: AuthShield.Resources.Schemas.User.t() | no_return()
Deletes a AuthShield.Resources.Schemas.User
register.
Similar to delete/1
but returns the struct or raises if the changeset is invalid.
get_by(filters)
View Sourceget_by(filters :: keyword()) :: AuthShield.Resources.Schemas.User.t() | nil
Gets a AuthShield.Resources.Schemas.User
register by its filters.
Exemples:
AuthShield.Resources.Users.get_by(email: "lucas@gmail.com")
get_by!(filters)
View Sourceget_by!(filters :: keyword()) :: AuthShield.Resources.Schemas.User.t() | no_return()
Gets a AuthShield.Resources.Schemas.User
register by its filters.
Similar to get_by/1
but returns the struct or raises if the changeset is invalid.
insert(params)
View Sourceinsert(params :: map()) :: success_response() | failed_response()
Creates a new AuthShield.Resources.Schemas.User
register.
For an user to be authenticate in the system it will need an credential,
so when we create an user we also creates a AuthShield.Credentials.Schemas.Password
that can be used to perform actions in AuthShield.Authentication
.
Exemples:
AuthShield.Resources.Users.insert(%{
first_name: "Lucas",
last_name: "Mesquita",
email: "lucas@gmail.com",
password_credential: %{password: "My_passw@rd2"}
})
insert!(params)
View Sourceinsert!(params :: map()) :: AuthShield.Resources.Schemas.User.t() | no_return()
Creates a new AuthShield.Resources.Schemas.User
register.
Similar to insert/1
but returns the struct or raises if the changeset is invalid.
list(filters \\ [])
View Sourcelist(filters :: keyword()) :: [AuthShield.Resources.Schemas.User.t()]
Returns a list of AuthShield.Resources.Schemas.User
by its filters
Exemples:
# Getting the all list
AuthShield.Resources.Users.list()
# Filtering the list by field
AuthShield.Resources.Users.list(name: "Lucas")
preload(user, fields)
View Sourcepreload(user :: AuthShield.Resources.Schemas.User.t(), fields :: keyword()) :: AuthShield.Resources.Schemas.User.t()
Preloads the user data by the given fields.
Exemples:
AuthShield.Resources.Users.preload(user, [:roles])
status(user, status)
View Sourcestatus(user :: AuthShield.Resources.Schemas.User.t(), status :: boolean()) :: success_response() | failed_response()
Changes a User
status.
Exemples:
AuthShield.Resources.Users.status(user, true)
status!(user, status)
View Sourcestatus!(user :: AuthShield.Resources.Schemas.User.t(), status :: boolean()) :: AuthShield.Resources.Schemas.User.t() | no_return()
Changes a AuthShield.Resources.Schemas.User
status.
Similar to status/1
but returns the struct or raises if the changeset is invalid.
update(user, params)
View Sourceupdate(user :: AuthShield.Resources.Schemas.User.t(), params :: map()) :: success_response() | failed_response()
Updates a AuthShield.Resources.Schemas.User
register.
Exemples:
AuthShield.Resources.Users.update(user, %{
first_name: "Marcos",
last_name: "Farias",
email: "marcos@gmail.com"
})
update!(user, params)
View Sourceupdate!(user :: AuthShield.Resources.Schemas.User.t(), params :: map()) :: AuthShield.Resources.Schemas.User.t() | no_return()
Updates a AuthShield.Resources.Schemas.User
register.
Similar to update/2
but returns the struct or raises if the changeset is invalid.