Sha256: a4ea494a862670eb51d092a163ece2a040e211509373f9a0a309a0ad967e6b56
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 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 redirect_path = if mapping = Devise.mappings[scope] "/#{mapping.as}/#{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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
devise-0.4.1 | lib/devise/failure.rb |
devise-0.4.0 | lib/devise/failure.rb |