debian-mirror-gitlab/app/services/users/email_verification/base_service.rb
2023-07-09 08:55:56 +05:30

28 lines
548 B
Ruby

# frozen_string_literal: true
module Users
module EmailVerification
class BaseService
VALID_ATTRS = %i[unlock_token confirmation_token].freeze
def initialize(attr:, user:)
@attr = attr
@user = user
validate_attr!
end
protected
attr_reader :attr, :user, :token
def validate_attr!
raise ArgumentError, 'Invalid attribute' unless attr.in?(VALID_ATTRS)
end
def digest
Devise.token_generator.digest(User, user.email, token)
end
end
end
end