debian-mirror-gitlab/app/services/users/validate_manual_otp_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

33 lines
1 KiB
Ruby
Raw Normal View History

2021-01-03 14:25:43 +05:30
# frozen_string_literal: true
module Users
2022-07-16 23:28:13 +05:30
class ValidateManualOtpService < BaseService
2021-02-22 17:27:13 +05:30
include ::Gitlab::Auth::Otp::Fortinet
2023-05-27 22:25:52 +05:30
include ::Gitlab::Auth::Otp::DuoAuth
2021-02-22 17:27:13 +05:30
2021-01-03 14:25:43 +05:30
def initialize(current_user)
@current_user = current_user
2021-02-22 17:27:13 +05:30
@strategy = if forti_authenticator_enabled?(current_user)
2022-07-16 23:28:13 +05:30
::Gitlab::Auth::Otp::Strategies::FortiAuthenticator::ManualOtp.new(current_user)
2021-02-22 17:27:13 +05:30
elsif forti_token_cloud_enabled?(current_user)
::Gitlab::Auth::Otp::Strategies::FortiTokenCloud.new(current_user)
2023-05-27 22:25:52 +05:30
elsif duo_auth_enabled?(current_user)
::Gitlab::Auth::Otp::Strategies::DuoAuth::ManualOtp.new(current_user)
2021-01-03 14:25:43 +05:30
else
::Gitlab::Auth::Otp::Strategies::Devise.new(current_user)
end
end
def execute(otp_code)
strategy.validate(otp_code)
rescue StandardError => ex
Gitlab::ErrorTracking.log_exception(ex)
2022-07-16 23:28:13 +05:30
error(ex.message)
2021-01-03 14:25:43 +05:30
end
private
attr_reader :strategy
end
end