Sha256: 2debd7ea8508853f94d06b5556209c12f22ffd6995c9c5b06b933621c7719276

Contents?: true

Size: 701 Bytes

Versions: 14

Compression:

Stored size: 701 Bytes

Contents

require 'devise/strategies/authenticatable'

module Devise
	module Strategies
		class SubdomainLogin < Authenticatable

			def subdomain
				request.subdomain
			end

			def valid?
				subdomain.present? && params["user"]
			end

			def authenticate!
				return fail!('Invalid email or password.') unless account = Mtdevise::Account.find_by(subdomain: subdomain)
				return fail!('Invalid email or password.') unless user = account.users.find_by(email: params["user"]["email"])
				return fail!('Invalid email or password.') unless user.valid_password?(params["user"]["password"])
				success! user
			end

		end 
	end 
end
Warden::Strategies.add(:subdomain_login, Devise::Strategies::SubdomainLogin)

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mtdevise-3.8.4 config/initializers/devise/strategies/subdomain.rb
mtdevise-3.8.3 config/initializers/devise/strategies/subdomain.rb
mtdevise-3.8.2 config/initializers/devise/strategies/subdomain.rb
mtdevise-3.8.1 config/initializers/devise/strategies/subdomain.rb
mtdevise-3.8.0 config/initializers/devise/strategies/subdomain.rb
mtdevise-3.7.0 config/initializers/devise/strategies/subdomain.rb
mtdevise-3.6.2 config/initializers/devise/strategies/subdomain.rb
mtdevise-3.6.1 config/initializers/devise/strategies/subdomain.rb
mtdevise-3.6.0 config/initializers/devise/strategies/subdomain.rb
mtdevise-3.5.11 config/initializers/devise/strategies/subdomain.rb
mtdevise-3.5.10 config/initializers/devise/strategies/subdomain.rb
mtdevise-3.5.9 config/initializers/devise/strategies/subdomain.rb
mtdevise-3.5.8 config/initializers/devise/strategies/subdomain.rb
mtdevise-3.5.7 config/initializers/devise/strategies/subdomain.rb