class Clearance::SignInGuard

The base class for {DefaultSignInGuard} and all custom sign in guards.

Sign in guards provide you with fine-grained control over the process of signing in a user. Each guard is run in order and can do one of the following:

Sign In Guards could be used, for instance, to require that a user confirm their email address before being allowed to sign in.

# in config/initializers/clearance.rb
Clearance.configure do |config|
  config.sign_in_guards = ["ConfirmationGuard"]
end

# in app/guards/confirmation_guard.rb
class ConfirmationGuard < Clearance::SignInGuard
  def call
    if signed_in? && current_user.email_confirmed?
      next_guard
    else
      failure("You must confirm your email address.")
    end
  end
end

Calling ‘success` or `failure` in any guard short circuits all of the remaining guards in the stack. In most cases, you will want to either call `failure` or `next_guard`. The {DefaultSignInGuard} will always be the final guard called and will handle calling `success` if appropriate.

The stack is designed such that calling ‘call` will eventually return {SuccessStatus} or {FailureStatus}, thus halting the chain.