Sha256: f777c67dc57691d42b134bd7c0cd034e995aeeb5bcda50ec483ad8eae9a65ced
Contents?: true
Size: 723 Bytes
Versions: 12
Compression:
Stored size: 723 Bytes
Contents
require 'g5_authentication_client' module Devise module G5 class AuthPasswordValidator attr_reader :model def initialize(authenticatable_model) @model = authenticatable_model end def valid_password?(password) begin auth_user = auth_client(password).me rescue OAuth2::Error => error raise unless error.code == 'invalid_resource_owner' rescue RuntimeError => error raise unless error.message =~ /Insufficient credentials/ end !auth_user.nil? end private def auth_client(password) G5AuthenticationClient::Client.new(username: model.email, password: password) end end end end
Version data entries
12 entries across 12 versions & 1 rubygems