z_auth (zotonic_core v1.0.0-rc.12)

Handle authentication of zotonic users. Also shows the logon screen when authentication is required.

Link to this section Summary

Functions

Set the user to 'confirmed'.
Check if the visitor has been authenticated. Assumes a completely initalized context.
Check if the user is enabled, an user is enabled when the rsc is published and within its publication date range.
Forget about the user being logged on.
Logon an user whose id we know, set all user prefs in the context.
Logon a username/password combination, checks passwords with m_identity.
Logon an user and redirect the user agent. The MQTT websocket MUST be connected.
Allow an admin user to switch to another user account.
Allow an admin user to switch to another user account.
Request the client's auth worker to re-authenticate as a new user

Link to this section Functions

Link to this function

confirm(UserId, Context)

-spec confirm(m_rsc:resource_id(), z:context()) -> {ok, z:context()} | {error, user_not_enabled}.
Set the user to 'confirmed'.
Link to this function

is_auth(Context)

-spec is_auth(z:context()) -> boolean().
Check if the visitor has been authenticated. Assumes a completely initalized context.
Link to this function

is_enabled(UserId, Context)

-spec is_enabled(m_rsc:resource_id(), z:context()) -> boolean().
Check if the user is enabled, an user is enabled when the rsc is published and within its publication date range.
Link to this function

logoff(Context)

-spec logoff(z:context()) -> z:context().
Forget about the user being logged on.
Link to this function

logon(UserId, Context)

-spec logon(m_rsc:resource_id(), z:context()) -> {ok, z:context()} | {error, user_not_enabled}.
Logon an user whose id we know, set all user prefs in the context.
Link to this function

logon_pw(Username, Password, Context)

-spec logon_pw(binary(), binary(), z:context()) -> {boolean(), z:context()}.
Logon a username/password combination, checks passwords with m_identity.
Link to this function

logon_redirect(UserId, Url, Context)

-spec logon_redirect(m_rsc:resource_id(), binary() | undefined, z:context()) -> ok | {error, term()}.
Logon an user and redirect the user agent. The MQTT websocket MUST be connected.
Link to this function

logon_switch(UserId, Context)

-spec logon_switch(m_rsc:resource_id(), z:context()) -> {ok, z:context()} | {error, eacces}.
Allow an admin user to switch to another user account.
Link to this function

logon_switch(UserId, SudoUserId, Context)

-spec logon_switch(m_rsc:resource_id(), m_rsc:resource_id(), z:context()) ->
                {ok, z:context()} | {error, eacces}.
Allow an admin user to switch to another user account.
Link to this function

switch_user(UserId, Context)

-spec switch_user(m_rsc:resource_id(), z:context()) -> ok | {error, eacces}.
Request the client's auth worker to re-authenticate as a new user