Aura.Users (Aura v0.9.3)
View SourceService module for interacting with Hex users
๐ Resources
- ๐ Hex
- ๐ Hex API Specifications
- ๐พ hexpm/hex_core
- ๐พ hexpm/hexpm
- ๐ฌ Contact the maintainer (he's happy to help!)
Summary
Functions
Requests a hex user be created
Grabs the hex user representing the currently authenticated user
Grabs a hex user, given their username_or_email
Resets a specified user's password
Streams audit logs, scoped to the current authenticated user
Functions
@spec create_user( username :: Aura.Common.username(), password :: String.t(), emails :: [Aura.Common.email()], opts :: list() ) :: {:ok, Aura.Model.HexUser.t()} | {:error, any()}
Requests a hex user be created
๐ Terms of Service
If your service is using hex.pm as a backend, you must have users to agree to Hex's Terms of Service
๐ท๏ธ Params
- opts :: option parameters used to modify requests
- password :: User's password
- username ::
Aura.Common.username/0
- emails :: [
Aura.Common.email/0
]
โคต๏ธ Returns
โ On Success
{:ok, %HexUser{...}}
โ On Failure
{:error, (some error)}
๐ป Examples
iex> Application.delete_env(:aura, :api_key)
iex> username = Faker.Internet.user_name()
iex> password = Faker.Internet.slug()
iex> emails = [Faker.Internet.email()]
iex> alias Aura.Users
iex> opts = [repo_url: "http://localhost:4000/api"]
iex> {:ok, _user} = Users.create_user(username, password, emails, opts)
๐ฉโ๐ป API Details
Method | Path | Controller | Action |
---|---|---|---|
POST | /users | UserController | :create |
@spec get_current_user(opts :: list()) :: {:ok, Aura.Model.HexUser.t()} | {:error, any()}
Grabs the hex user representing the currently authenticated user
๐ท๏ธ Params
- opts :: option parameters used to modify requests
โคต๏ธ Returns
โ On Success
{:ok, %HexUser{...}}
โ On Failure
{:error, (some error)}
๐ป Examples
iex> alias Aura.Users
iex> opts = [repo_url: "http://localhost:4000/api"]
iex> {:ok, _user} = Users.get_current_user(opts)
๐ฉโ๐ป API Details
Method | Path | Controller | Action |
---|---|---|---|
GET | /users/me | UserController | :me |
@spec get_user( username_or_email :: Aura.Common.username() | Aura.Common.email(), opts :: list() ) :: {:ok, Aura.Model.HexUser.t()} | {:error, any()}
Grabs a hex user, given their username_or_email
๐ท๏ธ Params
- opts :: option parameters used to modify requests
username_or_email ::
Aura.Common.username/0
|Aura.Common.email/0
โคต๏ธ Returns
โ On Success
{:ok, %HexUser{...}}
โ On Failure
{:error, (some error)}
๐ป Examples
iex> alias Aura.Users
iex> opts = [repo_url: "http://localhost:4000/api"]
iex> {:ok, _user} = Users.get_user("eric@example.com", opts)
๐ฉโ๐ป API Details
Method | Path | Controller | Action |
---|---|---|---|
GET | /users/:username_or_email | UserController | :show |
@spec reset_user_password( username_or_email :: Aura.Common.username() | Aura.Common.email(), opts :: list() ) :: :ok | {:error, any()}
Resets a specified user's password
๐ท๏ธ Params
- opts :: option parameters used to modify requests
username_or_email ::
Aura.Common.username/0
|Aura.Common.email/0
โคต๏ธ Returns
โ On Success
:ok
โ On Failure
{:error, (some error)}
๐ป Examples
iex> alias Aura.Users
iex> opts = [repo_url: "http://localhost:4000/api"]
iex> {:ok, user} = Users.get_current_user(opts)
iex> Users.reset_user_password(user.email, opts)
:ok
๐ฉโ๐ป API Details
Method | Path | Controller | Action |
---|---|---|---|
GET | /users/:username_or_email/reset | UserController | :reset |
@spec stream_audit_logs(opts :: list()) :: Enumerable.t()
Streams audit logs, scoped to the current authenticated user
๐ท๏ธ Params
- opts.page :: start from this page number
โคต๏ธ Returns
โ On Success
Stream.resource/3
๐ป Examples
iex> alias Aura.Users
iex> opts = [repo_url: "http://localhost:4000/api"]
iex> audit_logs = Users.stream_audit_logs(opts)
iex> Enum.empty?(audit_logs)
false
๐ฉโ๐ป API Details
Method | Path | Controller | Action |
---|---|---|---|
GET | /users/me/audit-logs | UserController | :audit_logs |