Sha256: 945e4c5ffe8f99273a086d500057c1abb04a64467218c746d04624029cd8a9eb
Contents?: true
Size: 684 Bytes
Versions: 3
Compression:
Stored size: 684 Bytes
Contents
Warden::Strategies.add(:password) do def subdomain ActionDispatch::Http::URL.extract_subdomains(request.host, 1) end def json_params unless params.empty? params else @json ||= env['rack.input'].gets JSON.parse(@json) end end def valid? subdomain.present? && json_params["user"] end def authenticate! account = Cadenero::V1::Account.find_by_subdomain(subdomain) if account u = account.users.find_by_email(json_params["user"]["email"]) if u.nil? || u.blank? fail! else u.authenticate(json_params["user"]["password"]) ? success!(u) : fail! end else fail! end end end
Version data entries
3 entries across 3 versions & 1 rubygems