2020-10-16 14:09:04 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Users
|
2022-05-12 05:08:08 -04:00
|
|
|
class ValidatePushOtpService < BaseService
|
2020-12-10 07:09:43 -05:00
|
|
|
include ::Gitlab::Auth::Otp::Fortinet
|
|
|
|
|
2020-10-16 14:09:04 -04:00
|
|
|
def initialize(current_user)
|
|
|
|
@current_user = current_user
|
2020-12-10 07:09:43 -05:00
|
|
|
@strategy = if forti_authenticator_enabled?(current_user)
|
2022-05-12 05:08:08 -04:00
|
|
|
::Gitlab::Auth::Otp::Strategies::FortiAuthenticator::PushOtp.new(current_user)
|
2020-10-16 14:09:04 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-05-12 05:08:08 -04:00
|
|
|
def execute
|
|
|
|
strategy.validate
|
2020-10-16 14:09:04 -04:00
|
|
|
rescue StandardError => ex
|
|
|
|
Gitlab::ErrorTracking.log_exception(ex)
|
2022-05-12 05:08:08 -04:00
|
|
|
error(ex.message)
|
2020-10-16 14:09:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
attr_reader :strategy
|
|
|
|
end
|
|
|
|
end
|