Module: Doorkeeper::DeviceAuthorizationGrant::OAuth::Helpers::UserCode

Defined in:
lib/doorkeeper/device_authorization_grant/oauth/helpers/user_code.rb

Overview

Simple module providing a method to generate a user code for device verification.

Class Method Summary collapse

Class Method Details

.generateString

Generates an alphanumeric user code for device verification, using SecureRandom generator.



28
29
30
31
32
33
34
# File 'lib/doorkeeper/device_authorization_grant/oauth/helpers/user_code.rb', line 28

def self.generate
  SecureRandom
    .random_number(MAX_NUMBER)
    .to_s(BASE)
    .upcase
    .rjust(MAX_LENGTH, '0')
end