Sha256: 9de75e8f524ed046fa54a05f67953de5a5b84d2ec4460824417a65e7218bd669
Contents?: true
Size: 842 Bytes
Versions: 7
Compression:
Stored size: 842 Bytes
Contents
# frozen_string_literal: true require 'g5_authentication_client' module Devise module G5 # Validate a user's G5 Auth credentials 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
7 entries across 7 versions & 1 rubygems