Copyright © 2009-2013 Marc Worrell Date: 2009-04-25
Behaviours: zotonic_model.
Authors: Marc Worrell (marc@worrell.nl).
bcrypt_hash() = {bcrypt, binary()}
hash() = bcrypt_hash() | sha1_salted_hash()
password() = iodata()
sha1_salted_hash() = {hash, binary(), binary()}
check_username_pw/3 | Return the rsc_id with the given username/password. |
check_username_pw/4 | Return the rsc_id with the given username/password. |
delete/2 | |
delete_by_type/3 | |
delete_by_type_and_key/4 | |
delete_username/2 | Delete an username from a resource. |
ensure_username_pw/2 | Ensure that the user has an associated username and password. |
generate_username/2 | |
get/2 | Fetch a specific identity entry. |
get_rsc/2 | Fetch all credentials belonging to the user "id". |
get_rsc/3 | |
get_rsc_by_type/3 | Fetch all credentials belonging to the user "id" and of a certain type. |
get_username/1 | Return the username of the current user. |
get_username/2 | Return the username of the resource id, undefined if no username. |
hash/1 | Hash a password, using bcrypt. |
hash_is_equal/2 | Compare if a password is the same as a hash. |
insert/4 | Create an identity record. |
insert/5 | |
insert_single/4 | |
insert_single/5 | |
insert_unique/4 | Create an unique identity record. |
insert_unique/5 | |
is_email_verified/1 | Check if the primary email address of the user is verified. |
is_email_verified/2 | |
is_peer_allowed/1 | Check if the tcp/ip peer address is a allowed ip address. |
is_reserved_name/1 | Prevent insert of reserved usernames. |
is_user/2 | Check if the resource has any credentials that will make him/her an user. |
is_valid_key/3 | |
is_verified/2 | Check if there is a verified identity for the user, beyond the username_pw. |
lookup_by_type_and_key/3 | |
lookup_by_type_and_key_multi/3 | |
lookup_by_username/2 | |
lookup_by_verify_key/2 | |
lookup_users_by_type_and_key/3 | |
lookup_users_by_verified_type_and_key/3 | |
m_get/3 | Fetch the value for the key from a model source. |
merge/3 | Move the identities of two resources, the identities are removed from the source id. |
needs_rehash/1 | Check if the password hash needs to be rehashed. |
normalize_key/2 | |
set_by_type/4 | |
set_by_type/5 | |
set_expired/3 | Mark the username_pw identity of an user as 'expired', this forces a prompt for a password reset on the next authentication. |
set_username/3 | Change the username of the resource id, only possible if there is already an username/password set. |
set_username_pw/4 | Set the username/password of a resource. |
set_verified/2 | Set the verified flag on a record by identity id. |
set_verified/4 | Set the verified flag on a record by rescource id, identity type and value (eg an user's email address). |
set_verify_key/2 |
check_username_pw(Username::binary() | string(), Password::binary() | string(), Context::z:context()) -> {ok, m_rsc:resource_id()} | {error, term()}
Return the rsc_id with the given username/password. If succesful then updates the 'visited' timestamp of the entry.
check_username_pw(Username::binary() | string(), Password::binary() | string(), QueryArgs::list() | map(), Context::z:context()) -> {ok, m_rsc:resource_id()} | {error, term()}
Return the rsc_id with the given username/password. If succesful then updates the 'visited' timestamp of the entry.
delete(IdnId, Context) -> any()
delete_by_type(Rsc::m_rsc:resource(), Type::atom(), Context::#context{}) -> ok
delete_by_type_and_key(Rsc::m_rsc:resource(), Type::atom(), Key::atom(), Context::#context{}) -> ok
delete_username(RscId::m_rsc:resource() | undefined, Context::z:context()) -> ok | {error, eacces | enoent}
Delete an username from a resource.
ensure_username_pw(Id::m_rsc:resource(), Context::#context{}) -> ok | {error, term()}
Ensure that the user has an associated username and password
generate_username(Id, Context) -> any()
get(IdnId, Context) -> any()
Fetch a specific identity entry.
get_rsc(Id::m_rsc:resource(), Context::#context{}) -> list()
Fetch all credentials belonging to the user "id"
get_rsc(Id::m_rsc:resource_id(), Type::atom() | binary(), Context::z:context()) -> list() | undefined
get_rsc_by_type(Id::m_rsc:resource(), Type::atom(), Context::#context{}) -> list()
Fetch all credentials belonging to the user "id" and of a certain type
get_username(Context::z:context()) -> binary() | undefined
Return the username of the current user
get_username(RscId::m_rsc:resource(), Context::z:context()) -> binary() | undefined
Return the username of the resource id, undefined if no username
hash(Pw::password()) -> bcrypt_hash()
Hash a password, using bcrypt
hash_is_equal(Pw::password(), X2::hash()) -> boolean()
Compare if a password is the same as a hash.
insert(Rsc::m_rsc:resource(), Type::atom(), Key::binary(), Context::#context{}) -> {ok, pos_integer()} | {error, invalid_key}
Create an identity record.
insert(Rsc, Type, Key, Props, Context) -> any()
insert_single(Rsc::m_rsc:resource(), Type::atom(), Key::binary(), Context::#context{}) -> {ok, pos_integer()} | {error, invalid_key}
insert_single(Rsc, Type, Key, Props, Context) -> any()
insert_unique(RscId, Type, Key, Context) -> any()
Create an unique identity record.
insert_unique(RscId, Type, Key, Props, Context) -> any()
is_email_verified(Context) -> any()
Check if the primary email address of the user is verified.
is_email_verified(UserId, Context) -> any()
is_peer_allowed(Context) -> any()
Check if the tcp/ip peer address is a allowed ip address
is_reserved_name(List) -> any()
Prevent insert of reserved usernames. See: http://tools.ietf.org/html/rfc2142 See: https://arstechnica.com/security/2015/03/bogus-ssl-certificate
is_user(Id::m_rsc:resource(), Context::z:context()) -> boolean()
Check if the resource has any credentials that will make him/her an user
is_valid_key(Type::binary() | atom(), Key::undefined | binary() | string(), Context::z:context()) -> boolean()
is_verified(RscId::m_rsc:resource_id(), Context::z:context()) -> boolean()
Check if there is a verified identity for the user, beyond the username_pw
lookup_by_type_and_key(Type, Key, Context) -> any()
lookup_by_type_and_key_multi(Type, Key, Context) -> any()
lookup_by_username(Key, Context) -> any()
lookup_by_verify_key(Key, Context) -> any()
lookup_users_by_type_and_key(Type, Key, Context) -> any()
lookup_users_by_verified_type_and_key(Type, Key, Context) -> any()
m_get(Rest::list(), Msg::zotonic_model:opt_msg(), Context::z:context()) -> zotonic_model:return()
Fetch the value for the key from a model source
merge(WinnerId::m_rsc:resource(), LoserId::m_rsc:resource(), Context::#context{}) -> ok | {error, term()}
Move the identities of two resources, the identities are removed from the source id.
needs_rehash(X1::hash()) -> boolean()
Check if the password hash needs to be rehashed.
normalize_key(Type, Key) -> any()
set_by_type(RscId::m_rsc:resource_id(), Type::string() | binary(), Key::string() | binary(), Context::z:context()) -> ok
set_by_type(RscId::m_rsc:resource_id(), Type::string() | binary(), Key::string() | binary(), Props::term(), Context::z:context()) -> ok
set_expired(UserId, X2, Context) -> any()
Mark the username_pw identity of an user as 'expired', this forces a prompt for a password reset on the next authentication.
set_username(Id::m_rsc:resource() | undefined, Username::binary() | string(), Context::z:context()) -> ok | {error, eacces | enoent | eexist}
Change the username of the resource id, only possible if there is already an username/password set
set_username_pw(Id::m_rsc:resource() | undefined, Username::binary() | string(), Password::binary() | string(), Context::z:context()) -> ok | {error, Reason::term()}
Set the username/password of a resource. Replaces any existing username/password.
set_verified(Id::m_rsc:resource_id(), Context::z:context()) -> ok | {error, notfound}
Set the verified flag on a record by identity id.
set_verified(RscId::m_rsc:resource_id(), Type::string() | binary() | atom(), Key::string() | binary(), Context::z:context()) -> ok | {error, badarg}
Set the verified flag on a record by rescource id, identity type and value (eg an user's email address).
set_verify_key(Id, Context) -> any()
Generated by EDoc