Class: Ronin::DB::UserName

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Model, Model::HasUniqueName, Model::Importable
Defined in:
lib/ronin/db/user_name.rb

Overview

Represents a user name and their associated credentials or email addresses.

Instance Attribute Summary collapse

Attributes included from Model::HasUniqueName

#name

Class Method Summary collapse

Methods included from Model::HasUniqueName

included

Methods included from Model::Importable

included

Methods included from Model

included

Instance Attribute Details

#created_atTime (readonly)

Tracks when the user-name was created.

Returns:

  • (Time)


51
# File 'lib/ronin/db/user_name.rb', line 51

attribute :created_at, :datetime

#credentialsArray<Credential>

Any credentials belonging to the user.

Returns:



57
# File 'lib/ronin/db/user_name.rb', line 57

has_many :credentials, dependent: :destroy

#email_addressesArray<EmailAddress>

The email addresses of the user.

Returns:



87
# File 'lib/ronin/db/user_name.rb', line 87

has_many :email_addresses, dependent: :destroy

#idInteger

The primary key of the user name.

Returns:

  • (Integer)


45
# File 'lib/ronin/db/user_name.rb', line 45

attribute :id, :integer

#notesArray<Note>

The associated notes.

Returns:

Since:

  • 0.2.0



95
# File 'lib/ronin/db/user_name.rb', line 95

has_many :notes, dependent: :destroy

#passwordsArray<Password>

Any passwords used with the user name.

Returns:

Since:

  • 0.2.0



81
# File 'lib/ronin/db/user_name.rb', line 81

has_many :passwords, through: :credentials

#service_credentialsArray<ServiceCredential>

The service credentials that use the user name.

Returns:

Since:

  • 0.2.0



65
# File 'lib/ronin/db/user_name.rb', line 65

has_many :service_credentials, through: :credentials

#web_credentialsArray<WebCredential>

Any web credentials that use the user name.

Returns:

Since:

  • 0.2.0



73
# File 'lib/ronin/db/user_name.rb', line 73

has_many :web_credentials, through: :credentials

Class Method Details

.import(name) ⇒ UserName

Imports a user name.

Parameters:

  • name (String)

    The user name to import.

Returns:

  • (UserName)

    The imported user name.



142
143
144
# File 'lib/ronin/db/user_name.rb', line 142

def self.import(name)
  create(name: name)
end

.lookup(name) ⇒ UserName?

Looks up the user name.

Parameters:

  • name (String)

    The user name to lookup.

Returns:

  • (UserName, nil)

    The found user name.



129
130
131
# File 'lib/ronin/db/user_name.rb', line 129

def self.lookup(name)
  find_by(name: name)
end

.with_password(password) ⇒ Array<UserName>

Queries all user names that are associated with the password.

Parameters:

  • password (String)

    The plain-text password.

Returns:

  • (Array<UserName>)

    The user names that are associated with the password.

Since:

  • 0.2.0



110
111
112
113
114
115
116
117
118
# File 'lib/ronin/db/user_name.rb', line 110

def self.with_password(password)
  joins(credentials: :password).where(
    credentials: {
      ronin_passwords: {
        plain_text: password
      }
    }
  )
end