Sha256: eaf372021e6c4c7fd1cd90fc79f92d66a14966c93d81f364fafe47ca4cb6798e
Contents?: true
Size: 1017 Bytes
Versions: 3
Compression:
Stored size: 1017 Bytes
Contents
module Challah # Allows authentication by username and password. class PasswordTechnique attr_accessor :user_model # 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_model.find_for_session(username) if user if user.valid_session? 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 user_model @user_model ||= Challah.user end def username? !!@username end def username @username end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
challah-1.6.1 | lib/challah/techniques/password_technique.rb |
challah-1.6.0 | lib/challah/techniques/password_technique.rb |
challah-1.5.0 | lib/challah/techniques/password_technique.rb |