Sha256: e908686570f5071150ac17ad48615f645f9c4aefeb09d10051528e4d41ece660
Contents?: true
Size: 906 Bytes
Versions: 23
Compression:
Stored size: 906 Bytes
Contents
module Challah # Allows authentication by username and password. class PasswordTechnique # grab the params we want from this request def initialize(session) @username = session.username? ? session.username : nil @password = session.password? ? session.password : nil end # if we can successfully authenticate, return a User instance, otherwise nil def authenticate if username? and password? user = ::User.find_for_session(username) if user if user.active? if user.authenticate(@password) return user end end user.failed_authentication! user = nil end end nil end def password? !!@password end def persist? true end def username? !!@username end def username @username end end end
Version data entries
23 entries across 22 versions & 2 rubygems