Haytni.RememberablePlugin (Haytni v0.7.0) View Source

This plugin makes artificialy last user's authentication by creating a cookie which stores a token for remembering the user.

This cookie is cleared when user's manually logout.

Configuration:

  • remember_for (default: {2, :week}): the period of validity of the token/which the user won't be asked for credentials

  • remember_cookie_name (default: "remember_token"): the name of the cookie holding the token for automatic sign in

  • remember_cookie_options (default: [http_only: true, extra: "SameSite=Strict"]): to set custom options of the cookie (options are: domain, max_age, path, http_only, secure and extra, see documentation of Plug.Conn.put_resp_cookie/4)

    stack Haytni.RememberablePlugin,
      remember_for: {2, :week},
      remember_cookie_name: "remember_token",
      remember_cookie_options: [http_only: true, extra: "SameSite=Strict"]

Routes: none

Link to this section Summary

Link to this section Functions

Link to this function

add_rememberme_cookie(conn, remember_token, config)

View Source

Specs

add_rememberme_cookie(
  conn :: Plug.Conn.t(),
  remember_token :: String.t(),
  config :: Haytni.RememberablePlugin.Config.t()
) :: Plug.Conn.t()

Sign remember_token then add it to conn response's cookies.

Returns the updated %Plug.Conn{} with our rememberme cookie

Callback implementation for Haytni.Plugin.fields/1.

Link to this function

files_to_install(base_path, web_path, scope, timestamp)

View Source

Callback implementation for Haytni.Plugin.files_to_install/4.

Link to this function

invalid?(user, module, config)

View Source

Callback implementation for Haytni.Plugin.invalid?/3.

Link to this function

on_delete_user(multi, user, module, config)

View Source

Callback implementation for Haytni.Plugin.on_delete_user/4.

Link to this function

on_email_change(multi, changeset, module, config)

View Source

Callback implementation for Haytni.Plugin.on_email_change/4.

Link to this function

on_failed_authentication(user, multi, keywords, module, config)

View Source

Callback implementation for Haytni.Plugin.on_failed_authentication/5.

Link to this function

on_registration(multi, module, config)

View Source

Callback implementation for Haytni.Plugin.on_registration/3.

Link to this function

routes(config, prefix_name, options)

View Source

Callback implementation for Haytni.Plugin.routes/3.

Link to this function

validate_create_registration(changeset, module, config)

View Source

Callback implementation for Haytni.Plugin.validate_create_registration/3.

Link to this function

validate_password(changeset, module, config)

View Source

Callback implementation for Haytni.Plugin.validate_password/3.

Link to this function

validate_update_registration(changeset, module, config)

View Source

Callback implementation for Haytni.Plugin.validate_update_registration/3.