Sha256: bbaa54659715fc90e78ef80bb40be411823849ffc7fd806c824177de16522d58
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
module Devise module Failure mattr_accessor :default_url # Failure application that will be called every time :warden is thrown from # any strategy or hook. Responsible for redirect the user to the sign in # page based on current scope and mapping. If no scope is given, redirect # to the default_url. def self.call(env) options = env['warden.options'] scope = options[:scope] params = case env['warden'].try(:message) when Symbol { env['warden'].message => true } when String { :message => env['warden'].message } else options[:params] end env['warden'].logout redirect_path = if mapping = Devise.mappings[scope] "#{mapping.parsed_path}/#{mapping.path_names[:sign_in]}" else "/#{default_url}" end headers = {} headers["Location"] = redirect_path headers["Location"] << "?" << Rack::Utils.build_query(params) if params headers["Content-Type"] = 'text/plain' message = options[:message] || "You are being redirected to #{redirect_path}" [302, headers, [message]] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ramon-devise-0.4.2 | lib/devise/failure.rb |