authentication_method.rb 773 B

1234567891011121314151617181920212223242526272829
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Auth::TwoFactor::AuthenticationMethod < Auth::TwoFactor::Method
  3. include Mixin::RequiredSubPaths
  4. # Implement it in the real method itself if you need it.
  5. # This needs to be used for e.g. sending out emails or SMS.
  6. def initiate_authentication; end
  7. def verify(payload, configuration = user_two_factor_preference_configuration)
  8. raise NotImplementedError
  9. end
  10. def initiate_configuration
  11. raise NotImplementedError
  12. end
  13. def available?
  14. true
  15. end
  16. def related_setting_name
  17. "two_factor_authentication_method_#{method_name}"
  18. end
  19. def user_two_factor_preference
  20. user&.two_factor_preferences&.authentication_methods&.find_by(method: method_name)
  21. end
  22. end