Boruta v0.1.0-rc.1 Boruta.Oauth.Token View Source

Oauth token Schema

Persist Token into database, provide some utilities too.

Link to this section Summary

Functions

Determines if a token is expired

Link to this section Types

Link to this type

t() View Source
t() :: %Boruta.Oauth.Token{
  __meta__: term(),
  client: Boruta.Oauth.Client.t(),
  client_id: term(),
  expires_at: integer(),
  id: term(),
  inserted_at: term(),
  redirect_uri: String.t(),
  refresh_token: term(),
  resource_owner: struct(),
  resource_owner_id: term(),
  scope: String.t(),
  state: String.t(),
  type: String.t(),
  updated_at: term(),
  value: String.t()
}

Link to this section Functions

Link to this function

expired?(token) View Source
expired?(%Boruta.Oauth.Token{
  __meta__: term(),
  client: term(),
  client_id: term(),
  expires_at: integer(),
  id: term(),
  inserted_at: term(),
  redirect_uri: term(),
  refresh_token: term(),
  resource_owner: term(),
  resource_owner_id: term(),
  scope: term(),
  state: term(),
  type: term(),
  updated_at: term(),
  value: term()
}) :: :ok | {:error, any()}

Determines if a token is expired

Examples

iex> expired?(%Boruta.Oauth.Token{expires_at: 1638316800}) # 1st january 2021
:ok

iex> expired?(%Boruta.Oauth.Token{expires_at: 0}) # 1st january 1970
{:error, "Token expired."}