authentication_method.rb 802 B

123456789101112131415161718192021222324252627282930
  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. # TODO: Add documentation.
  8. def verify(payload, configuration = user_two_factor_preference_configuration)
  9. raise NotImplementedError
  10. end
  11. def initiate_configuration
  12. raise NotImplementedError
  13. end
  14. def available?
  15. true
  16. end
  17. def related_setting_name
  18. "two_factor_authentication_method_#{method_name}"
  19. end
  20. def user_two_factor_preference
  21. user&.two_factor_preferences&.authentication_methods&.find_by(method: method_name)
  22. end
  23. end