debian-mirror-gitlab/app/services/users/email_verification/generate_token_service.rb
2022-10-11 01:57:18 +05:30

21 lines
396 B
Ruby

# frozen_string_literal: true
module Users
module EmailVerification
class GenerateTokenService < EmailVerification::BaseService
TOKEN_LENGTH = 6
def execute
@token = generate_token
[token, digest]
end
private
def generate_token
SecureRandom.random_number(10**TOKEN_LENGTH).to_s.rjust(TOKEN_LENGTH, '0')
end
end
end
end