Sha256: 5eae52ada78adc646486e9b304e52baae9ecf0f04df47b2b9b072443f4867372
Contents?: true
Size: 947 Bytes
Versions: 8
Compression:
Stored size: 947 Bytes
Contents
module Challah class PasswordProvider def self.save(user) set(uid: user.username, token: user.password, user_id: user.id) end def self.set(options = {}) user_id = options.fetch(:user_id) uid = options.fetch(:uid, '') token = options.fetch(:token, '') if token.to_s.blank? authorization = ::Authorization.get({ user_id: user_id, provider: :password }) if authorization token = authorization.token end else token = Challah::Encrypter.encrypt(token) end ::Authorization.set({ provider: :password, user_id: user_id, uid: uid, token: token }) end def self.valid?(record) password_validator = Challah.options[:password_validator] password_validator.new(force: true).validate(record) record.errors[:password].size.zero? end end end
Version data entries
8 entries across 8 versions & 1 rubygems