Module: StandardId::LifecycleHooks

Extended by:
ActiveSupport::Concern
Included in:
Web::Auth::Callback::ProvidersController, Web::LoginController, Web::LoginVerifyController, Web::SignupController
Defined in:
app/controllers/concerns/standard_id/lifecycle_hooks.rb

Overview

Public concern providing authentication lifecycle hook invocations.

Include this in host app controllers that implement custom authentication flows but want to participate in StandardId’s hook system. The hooks are configured via ‘StandardId.config.before_sign_in`, `after_sign_in`, and `after_account_created` callbacks.

This is the same concern used internally by the WebEngine’s built-in controllers – there is no separate “internal” version.

Requires the including controller to include ‘StandardId::WebAuthentication` (for `session_manager` and `request` access).

Examples:

Usage in a host app controller

class Auth::SessionsController < ApplicationController
  include StandardId::WebAuthentication
  include StandardId::LifecycleHooks

  def create
     = authenticate_somehow(params)
    (, { mechanism: "custom", provider: nil })
    session_manager.()
    redirect_override = (, { mechanism: "custom", provider: nil })
    redirect_to redirect_override || root_path
  rescue StandardId::AuthenticationDenied => e
    handle_authentication_denied(e)
  end
end

Constant Summary collapse

DEFAULT_PROFILE_RESOLVER =

Default profile resolver when StandardId.config.profile_resolver is nil.

->(acct, pt) { acct.profiles.exists?(profileable_type: pt) }