Class: SignIn::RefreshToken

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/models/sign_in/refresh_token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session_handle:, user_uuid:, anti_csrf_token:, uuid: create_uuid, parent_refresh_token_hash: nil, nonce: create_nonce, version: Constants::RefreshToken::CURRENT_VERSION) ⇒ RefreshToken

rubocop:disable Metrics/ParameterLists



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/sign_in/refresh_token.rb', line 13

def initialize(session_handle:,
               user_uuid:,
               anti_csrf_token:,
               uuid: create_uuid,
               parent_refresh_token_hash: nil,
               nonce: create_nonce,
               version: Constants::RefreshToken::CURRENT_VERSION)
  @user_uuid = user_uuid
  @uuid = uuid
  @session_handle = session_handle
  @parent_refresh_token_hash = parent_refresh_token_hash
  @anti_csrf_token = anti_csrf_token
  @nonce = nonce
  @version = version

  validate!
end

Instance Attribute Details

#anti_csrf_tokenObject (readonly)

Returns the value of attribute anti_csrf_token.



7
8
9
# File 'app/models/sign_in/refresh_token.rb', line 7

def anti_csrf_token
  @anti_csrf_token
end

#nonceObject (readonly)

Returns the value of attribute nonce.



7
8
9
# File 'app/models/sign_in/refresh_token.rb', line 7

def nonce
  @nonce
end

#parent_refresh_token_hashObject (readonly)

Returns the value of attribute parent_refresh_token_hash.



7
8
9
# File 'app/models/sign_in/refresh_token.rb', line 7

def parent_refresh_token_hash
  @parent_refresh_token_hash
end

#session_handleObject (readonly)

Returns the value of attribute session_handle.



7
8
9
# File 'app/models/sign_in/refresh_token.rb', line 7

def session_handle
  @session_handle
end

#user_uuidObject (readonly)

Returns the value of attribute user_uuid.



7
8
9
# File 'app/models/sign_in/refresh_token.rb', line 7

def user_uuid
  @user_uuid
end

#uuidObject (readonly)

Returns the value of attribute uuid.



7
8
9
# File 'app/models/sign_in/refresh_token.rb', line 7

def uuid
  @uuid
end

#versionObject (readonly)

Returns the value of attribute version.



7
8
9
# File 'app/models/sign_in/refresh_token.rb', line 7

def version
  @version
end

Instance Method Details

#create_nonceObject (private)



51
52
53
# File 'app/models/sign_in/refresh_token.rb', line 51

def create_nonce
  SecureRandom.hex
end

#create_uuidObject (private)



47
48
49
# File 'app/models/sign_in/refresh_token.rb', line 47

def create_uuid
  SecureRandom.uuid
end

#persisted?Boolean

rubocop:enable Metrics/ParameterLists

Returns:

  • (Boolean)


32
33
34
# File 'app/models/sign_in/refresh_token.rb', line 32

def persisted?
  false
end

#to_sObject



36
37
38
39
40
41
42
43
# File 'app/models/sign_in/refresh_token.rb', line 36

def to_s
  {
    uuid:,
    user_uuid:,
    session_handle:,
    version:
  }
end