Coherence v0.3.0 Coherence.ControllerHelpers
Common helper functions for Coherence Controllers.
Summary
Functions
Confirm a user account
Test if a datetime has expired
Lock a use account
Log an error message when lockable update fails
Get the configured logged_out_url
Get a random string of given length
Plug to redirect already logged in users
Get the MyProject.Router.Helpers module
Send confirmation email with token
Send a user email
Unlock a user account
Functions
Confirm a user account.
Adds the :confirmed_at
datetime field on the user model and updates the database
Test if a datetime has expired.
Convert the datetime from Ecto.DateTime format to Timex format to do the comparison given the time during in opts.
Examples
expired?(user.expire_at, days: 5)
expired?(user.expire_at, minutes: 10)
Lock a use account.
Sets the :locked_at
field on the user model to the current date and time unless
provided a value for the optional parameter.
You can provide a date in the future to override the configured lock expiry time. You can set this data far in the future to do a pseudo permanent lock.
Get a random string of given length.
Returns a random url safe encoded64 string of the given length. Used to generate tokens for the various modules that require unique tokens.
Get the MyProject.Router.Helpers module.
Returns the projects Router.Helpers module.
Send confirmation email with token.
If the user supports confirmable, generate a token and send the email.
Send a user email.
Sends a user email given the module, model, and url. Logs the email for debug purposes.
Note: This function uses an apply to avoid compile warnings if the mailer is not selected as an option.