Sha256: 98fd9fa9e07b3ba3a40a7a3ad3cdc791263244b44a372f1d376aabfb339659de

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

require 'quo_vadis/engine'

module QuoVadis

  #
  # Redirection URLs
  #

  # The URL to redirect the user to after s/he signs in.
  mattr_accessor :signed_in_url
  @@signed_in_url = :root

  # Whether the `:signed_in_url` should override the URL the user was trying
  # to reach when they were made to authenticate.
  mattr_accessor :override_original_url
  @@override_original_url = false

  def self.signed_in_url(user, original_url)
    if original_url && !@@override_original_url
      original_url
    else
      @@signed_in_url.respond_to?(:call) ?  @@signed_in_url.call(user) : @@signed_in_url
    end
  end

  # The URL to redirect the user to after s/he signs out.
  mattr_accessor :signed_out_url
  @@signed_in_url = :root


  #
  # Hooks
  #

  # Code to run when the user has signed in.
  mattr_accessor :signed_in_hook
  @@signed_in_hook = nil

  def self.signed_in_hook(user, controller)
    @@signed_in_hook.call(user, controller) if @@signed_in_hook
  end

  # Code to run when someone has tried but failed to sign in.
  mattr_accessor :failed_sign_in_hook
  @@failed_sign_in_hook = nil

  def self.failed_sign_in_hook(controller)
    @@failed_sign_in_hook.call(controller) if @@failed_sign_in_hook
  end

  # Code to run just before the user has signed out.
  mattr_accessor :signed_out_hook
  @@signed_out_hook = nil

  def self.signed_out_hook(user, controller)
    @@signed_out_hook.call(user, controller) if @@signed_out_hook
  end


  #
  # Miscellaneous
  #

  # Layout for the sign-in view.
  mattr_accessor :layout
  @@layout = nil


  # Configure from the initializer.
  def self.configure
    yield self
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quo_vadis-1.0.1 lib/quo_vadis.rb