cassette v1.5.0 Cassette.User

This is the struct that represents the user returned by a Validation request

Link to this section Summary

Functions

Initializes a Cassette.User struct, mapping the list of authorities to it’s internal representation

Initializes a Cassette.User struct, with a type attribute and mapping the list of authorities to it’s internal representation

Initializes a Cassette.User struct, with a type attribute, mapping the list of authorities, and any extra attribute returned by the server

Tests if the user has the given role. This function does not alter the role when checking against the list of authorities

Tests if the user has the given role respecting the base_authority set in the default configuration

Tests if the user has the given role using the base_authority set in the default configuration

Link to this section Types

Link to this type t()
t() :: %Cassette.User{attributes: map(), authorities: term(), login: String.t(), type: term()}

Link to this section Functions

Link to this function has_raw_role?(user, role)
Link to this function has_role?(user, role)
Link to this function has_role?(user, config, role)
Link to this function new(login, authorities)
new(String.t(), [String.t()]) :: Cassette.User.t()

Initializes a Cassette.User struct, mapping the list of authorities to it’s internal representation

Link to this function new(login, type, authorities)

Initializes a Cassette.User struct, with a type attribute and mapping the list of authorities to it’s internal representation

Link to this function new(login, type, authorities, attributes)
new(String.t(), String.t(), [String.t()], map()) :: Cassette.User.t()

Initializes a Cassette.User struct, with a type attribute, mapping the list of authorities, and any extra attribute returned by the server

Link to this function raw_role?(arg1, raw_role)
raw_role?(Cassette.User.t() | any(), String.t() | any()) :: boolean()

Tests if the user has the given role. This function does not alter the role when checking against the list of authorities.

If your user has the ACME_ADMIN authority the following is true:

iex> Cassette.User.raw_role?(some_user, "ACME_ADMIN")
true
iex> Cassette.User.has_raw_role?(some_user, "ACME_ADMIN")
true

This function returns false when user is not a Cassette.User.t

Link to this function role?(user, role)
role?(Cassette.User.t() | any(), String.t() | any()) :: boolean()

Tests if the user has the given role respecting the base_authority set in the default configuration

If your base_authority is ACME and the user has the ACME_ADMIN authority, then the following is true:

iex> Cassette.User.role?(some_user, "ADMIN")
true
iex> Cassette.User.has_role?(some_user, "ADMIN")
true

This function returns false when user is not a Cassette.User.t

Link to this function role?(user, arg2, role)
role?(Cassette.User.t() | any(), Cassette.Config.t() | any(), String.t() | any()) :: boolean()

Tests if the user has the given role using the base_authority set in the default configuration

If you are using custom a Cassette.Support server you can use this function to respect it’s base_authority

This function returns false when user is not a Cassette.User.t