View Source ArkeAuth.Core.Auth (arke_auth v0.3.4)

ArkeAuth.Core.Auth documentation

Summary

Functions

Change the user password

Create new access_token and refresh_token exchanging the user refresh token

Update the user data

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

Functions

Link to this function

change_password(user, old_pwd, new_pwd)

View Source
@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

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

Return

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

create_tokens(resource, sso \\ "default")

View Source
Link to this function

get_project_member(project, user)

View Source
Link to this function

refresh_tokens(user, token)

View Source
@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

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

Returns

{:ok, access_token, refresh_token}
{:error, msg}
@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

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

Example

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

Return

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

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

View Source
@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

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

Example

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

Return

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