diff options
Diffstat (limited to 'app/services/users/email_verification/base_service.rb')
-rw-r--r-- | app/services/users/email_verification/base_service.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/services/users/email_verification/base_service.rb b/app/services/users/email_verification/base_service.rb new file mode 100644 index 00000000000..3337beec195 --- /dev/null +++ b/app/services/users/email_verification/base_service.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Users + module EmailVerification + class BaseService + VALID_ATTRS = %i[unlock_token confirmation_token].freeze + + def initialize(attr:) + @attr = attr + + validate_attr! + end + + protected + + attr_reader :attr, :token + + def validate_attr! + raise ArgumentError, 'Invalid attribute' unless attr.in?(VALID_ATTRS) + end + + def digest + Devise.token_generator.digest(User, attr, token) + end + end + end +end |