Sha256: 93c4855cf61050470d7453fcadf73d02eb45e9c9f2be65c663c37e69328c6469
Contents?: true
Size: 1.33 KB
Versions: 4
Compression:
Stored size: 1.33 KB
Contents
# frozen_string_literal: true module RailsBase::Authentication class SsoVerifyEmail < RailsBase::ServiceBase delegate :verification, to: :context def call datum = get_short_lived_datum(verification) validate_datum?(datum) user = datum[:user] user.update(email_validated: true) context.user = datum[:user] params = { expires_at: Time.zone.now + Constants::SVE_TTL, user: user, purpose: Constants::SSOVE_PURPOSE } context.encrypted_val = RailsBase::Mfa::EncryptToken.(params).encrypted_val end def validate_datum?(datum) return true if datum[:valid] if datum[:found] msg = "Errors with Email Verification: #{datum[:invalid_reason].join(", ")}. Please login again" log(level: :warn, msg: msg) context.fail!(message: msg, redirect_url: Constants::URL_HELPER.new_user_session_path, level: :warn) end log(level: :warn, msg: "Could not find MFA code. Incorrect Email verification code. User may be doing Fishyyyyy things") context.fail!(message: "Invalid Email Verification Code. Log in again.", redirect_url: Constants::URL_HELPER.new_user_session_path, level: :warn) end def get_short_lived_datum(mfa_code) ShortLivedData.find_datum(data: mfa_code, reason: Constants::SVE_LOGIN_REASON) end def validate! raise "verification is expected" if verification.nil? end end end
Version data entries
4 entries across 4 versions & 1 rubygems