Welcome to mirror list, hosted at ThFree Co, Russian Federation.

base_service.rb « email_verification « users « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3337beec1951fd2f50c6068deef0f29321d7b6ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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