two_factor_configuration.rb 547 B

123456789101112131415161718
  1. # Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
  2. class Auth::AfterAuth::TwoFactorConfiguration < Auth::AfterAuth::Backend
  3. def check
  4. return false if session[:authentication_type] != 'password'
  5. return false if !user.two_factor_setup_required?
  6. issue_password_revalidation_token if options[:initial]
  7. true
  8. end
  9. private
  10. def issue_password_revalidation_token
  11. @data[:token] = Token.create(action: 'PasswordCheck', user_id: user.id, persistent: false, expires_at: 1.hour.from_now).token
  12. end
  13. end