Class: ApiEngineBase::LoginStrategy::PlainText::EmailVerification::Verify

Inherits:
ServiceBase
  • Object
show all
Defined in:
app/services/api_engine_base/login_strategy/plain_text/email_verification/verify.rb

Constant Summary

Constants inherited from ServiceBase

ServiceBase::ON_ARGUMENT_VALIDATION

Instance Method Summary collapse

Methods inherited from ServiceBase

inherited, #internal_validate, #service_base_logging, #validate!

Methods included from ArgumentValidation

included

Methods included from ServiceLogging

#aletered_message, #class_name, #log, #log_error, #log_info, #log_prefix, #log_warn, #logger, #service_id

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/services/api_engine_base/login_strategy/plain_text/email_verification/verify.rb', line 10

def call
  result = ApiEngineBase::Secrets::Verify.(secret: code, reason: ApiEngineBase::Secrets::EMAIL_VERIFICIATION)
  if result.failure?
    inline_argument_failure!(errors: { code:  "Incorrect verification code provided" })
  end

  if result.user != user
    log_warn("Yikes! The logged in user does not match the correct code. Kick them back out and do not verify")
    inline_argument_failure!(errors: { code:  "Incorrect verification code provided" })
  end

  user.update(email_validated: true)
end