ArkeAuth.Core.Auth (arke_auth v0.1.2)

ArkeAuth.Core.Auth documentation

Link to this section Summary

Link to this section Functions

Link to this function

arke_from_attr()

Link to this function

base_parameters()

Link to this function

before_create(arke, unit)

Link to this function

before_delete(arke, unit)

Link to this function

before_load(data, persistence_fn)

Link to this function

before_update(arke, unit)

Link to this function

before_validate(arke, unit)

Link to this function

change_password(user, old_pwd, new_pwd)

@spec change_password(
  user :: Arke.Core.Unit.t(),
  old_pwd :: String.t(),
  new_pwd :: String.t()
) ::
  {:ok, Arke.Core.Unit.t()} | Arke.Utils.ErrorGenerator.t()

Change the user password

parameter

Parameter

  • user => %Arke.Core.Unit{} => the unit struct representing the user
  • old_pwd => string => the old password
  • new_pwd => string => the new password

return

Return

{:ok, %Arke.Core.Unit{}}
{:error, msg}
Link to this function

groups_from_attr()

Link to this function

on_create(arke, unit)

Link to this function

on_delete(arke, unit)

Link to this function

on_load(data, persistence_fn)

Link to this function

on_update(arke, unit)

Link to this function

on_validate(arke, unit)

Link to this function

refresh_tokens(user, token)

@spec refresh_tokens(user :: Arke.Core.Unit.t(), token :: String.t()) ::
  {:ok, new_token :: String.t(), refresh_token :: String.t()}
  | Arke.Utils.ErrorGenerator.t()

Create new access_token and refresh_token exchanging the user refresh token

parameter

Parameter

  • user => %Arke.Core.Unit{} => the unit struct representing the user
  • token => the refresh_token to exchange

returns

Returns

{:ok, access_token, refresh_token}
{:error, msg}
Link to this function

update(user, data)

@spec update(user :: Arke.Core.Unit.t(), data :: [ArkeAuth.Core.User.t()]) ::
  {:ok, Arke.Core.Unit.t()} | Arke.Utils.ErrorGenerator.t()

Update the user data

parameters

Parameters

  • user => %Arke.Core.Unit{} => the user to update
  • data => %map => map containing all the data to update

example

Example

iex> params = [username: "test", password: "password", type: "customer"]
...> user = Arke.QuseryManager.get_by(id: "test")
...> ArkeAuth.Core.update(user, params)

return

Return

{:ok, %Arke.Core.Unit{}}
{:error, msg}
Link to this function

validate_credentials(username, password, project \\ :arke_system)

@spec validate_credentials(
  username :: String.t(),
  password :: String.t(),
  project :: atom()
) ::
  {:ok, Arke.Core.Unit.t()} | Arke.Utils.ErrorGenerator.t()

Implementation for the login. It verify the given username and password

parameters

Parameters

  • username => string => user's username
  • password => string => user's password

example

Example

iex> ArkeAuth.Core.validate_credentials("test", "password_test")

return

Return

{:ok, %ArkeAuth.Core.User{}}