Class: Users::EmailVerification::ValidateTokenService

Inherits:
BaseService
  • Object
show all
Includes:
ActionView::Helpers::DateHelper
Defined in:
app/services/users/email_verification/validate_token_service.rb

Constant Summary collapse

TOKEN_VALID_FOR_MINUTES =
60

Constants inherited from BaseService

BaseService::VALID_ATTRS

Instance Method Summary collapse

Constructor Details

#initialize(attr:, user:, token:) ⇒ ValidateTokenService

Returns a new instance of ValidateTokenService.



10
11
12
13
14
# File 'app/services/users/email_verification/validate_token_service.rb', line 10

def initialize(attr:, user:, token:)
  super(attr: attr, user: user)

  @token = token
end

Instance Method Details

#executeObject



16
17
18
19
20
21
22
# File 'app/services/users/email_verification/validate_token_service.rb', line 16

def execute
  return failure(:rate_limited) if verification_rate_limited?
  return failure(:invalid) unless valid?
  return failure(:expired) if expired_token?

  success
end