]> cat aescling's git repositories - mastodon.git/blob - lib/devise/two_factor_pam_authenticatable.rb
Fix authentication before 2FA challenge (#11943)
[mastodon.git] / lib / devise / two_factor_pam_authenticatable.rb
1 # frozen_string_literal: true
2
3 require 'devise/strategies/base'
4
5 module Devise
6 module Strategies
7 class TwoFactorPamAuthenticatable < Base
8 def valid?
9 valid_params? && mapping.to.respond_to?(:authenticate_with_pam)
10 end
11
12 def authenticate!
13 resource = mapping.to.authenticate_with_pam(params[scope])
14
15 if resource && !resource.otp_required_for_login?
16 success!(resource)
17 else
18 fail(:invalid)
19 end
20 end
21
22 protected
23
24 def valid_params?
25 params[scope] && params[scope][:password].present?
26 end
27 end
28 end
29 end
30
31 Warden::Strategies.add(:two_factor_pam_authenticatable, Devise::Strategies::TwoFactorPamAuthenticatable)
This page took 0.075484 seconds and 4 git commands to generate.