Sha256: d8e78e5b1bb725e2e3d2b0932a1370385da90f0ab68942d14bc5d407e97d22a7

Contents?: true

Size: 1.3 KB

Versions: 29

Compression:

Stored size: 1.3 KB

Contents

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 = MfaSetEncryptToken.call(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

29 entries across 29 versions & 1 rubygems

Version Path
rails_base-0.75.6 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.75.5 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.75.4 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.75.3 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.75.2 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.75.1 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.75.0 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.74.0 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.73.1 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.73.0 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.72.1 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.72.0 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.71.0 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.70.1.pre app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.70.0 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.61.0 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.60.0 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.58.0 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.57.0 app/services/rails_base/authentication/sso_verify_email.rb
rails_base-0.56.0 app/services/rails_base/authentication/sso_verify_email.rb