Class: Arkaan::Account

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::SecurePassword, Concerns::Enumerable, Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/arkaan/account.rb

Overview

A user account with all related attributes. It holds credentials and informations about a designated user.

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#applicationsArray<Arkaan::OAuth::Application] the applications this user has created and owns.

Returns Array<Arkaan::OAuth::Application] the applications this user has created and owns.

Returns:



46
# File 'lib/arkaan/account.rb', line 46

has_many :applications, class_name: 'Arkaan::OAuth::Application', inverse_of: :creator

#authorizationsArray<Arkaan::OAuth::Authorization>

Returns the authorization issued by this account to third-party applications to access its data.

Returns:



50
# File 'lib/arkaan/account.rb', line 50

has_many :authorizations, class_name: 'Arkaan::OAuth::Authorization', inverse_of: :account

#emailString

Returns the email address of the user, useful to contact them.

Returns:

  • (String)

    the email address of the user, useful to contact them.



26
# File 'lib/arkaan/account.rb', line 26

field :email, type: String

#firstnameString

Returns the first name of the user.

Returns:

  • (String)

    the first name of the user.



23
# File 'lib/arkaan/account.rb', line 23

field :firstname, type: String, default: ''

#genderSymbol

Returns the way you prefer the application to gender you.

Returns:

  • (Symbol)

    the way you prefer the application to gender you.



32
# File 'lib/arkaan/account.rb', line 32

enum_field :gender, %i[female male neutral], default: :neutral

#groupsArray<Arkaan::Permissions::Group>

Returns the groups giving their corresponding rights to the current account.

Returns:



42
# File 'lib/arkaan/account.rb', line 42

has_and_belongs_to_many :groups, class_name: 'Arkaan::Permissions::Group', inverse_of: :accounts

#invitationsArray<Arkaan::Campaigns::Invitation>

Returns the invitations you’ve issued yourself to other players.

Returns:



59
# File 'lib/arkaan/account.rb', line 59

has_many :invitations, class_name: 'Arkaan::Campaigns::Invitation', inverse_of: :account

#languageSymbol

Returns the language preferred by this user.

Returns:

  • (Symbol)

    the language preferred by this user.



29
# File 'lib/arkaan/account.rb', line 29

enum_field :language, %i[en_GB fr_FR], default: :fr_FR

#lastnameString

Returns the last name (family name) of the user.

Returns:

  • (String)

    the last name (family name) of the user.



20
# File 'lib/arkaan/account.rb', line 20

field :lastname, type: String, default: ''

#messagesArray<Arkaan::Chatrooms::Messages>

Returns all the messages ever sent by the user.

Returns:

  • (Array<Arkaan::Chatrooms::Messages>)

    all the messages ever sent by the user.



68
# File 'lib/arkaan/account.rb', line 68

has_many :messages, class_name: 'Arkaan::Chatrooms::Message', inverse_of: :account

#notificationsArray<Arkaan::Notification>

Returns the notifications linked to this user.

Returns:



74
# File 'lib/arkaan/account.rb', line 74

embeds_many :notifications, class_name: 'Arkaan::Notification', inverse_of: :account

#password=(value) ⇒ String (writeonly)

Returns password, in clear, of the user if you just changed it.

Returns:

  • (String)

    password, in clear, of the user if you just changed it.



38
# File 'lib/arkaan/account.rb', line 38

has_secure_password validations: false

#password_confirmation=(value) ⇒ String (writeonly)

Returns the confirmation of the password, that matches the password itself.

Returns:

  • (String)

    the confirmation of the password, that matches the password itself.



38
# File 'lib/arkaan/account.rb', line 38

has_secure_password validations: false

#password_digestString (readonly)

Returns the password of the user, encrypted with the Blowfish algorithm.

Returns:

  • (String)

    the password of the user, encrypted with the Blowfish algorithm.



17
# File 'lib/arkaan/account.rb', line 17

field :password_digest, type: String

#permissionsArray<Arkaan::Files::Permission>

Returns the file access permissions granted to this account.

Returns:



65
# File 'lib/arkaan/account.rb', line 65

has_many :permissions, class_name: 'Arkaan::Files::Permission', inverse_of: :account

#servicesArray<Arkaan::Monitoring::Service>

Returns the services created by this user.

Returns:



53
# File 'lib/arkaan/account.rb', line 53

has_many :services, class_name: 'Arkaan::Monitoring::Service', inverse_of: :creator

#sessionsArray<Arkaan::Authentication::Session>

Returns the sessions on which this account is, or has been logged in.

Returns:



56
# File 'lib/arkaan/account.rb', line 56

has_many :sessions, class_name: 'Arkaan::Authentication::Session', inverse_of: :account

#usernameString

Returns the current name identifying the user on the GUI.

Returns:

  • (String)

    the current name identifying the user on the GUI.



14
# File 'lib/arkaan/account.rb', line 14

field :username, type: String

Instance Method Details

#read_notificationsArray<Arkaan::Notification>

Returns the notifications already read byt the user.

Returns:



82
83
84
# File 'lib/arkaan/account.rb', line 82

def read_notifications
  notifications.where(read: true)
end

#unread_notificationsArray<Arkaan::Notification>

Returns the unread notifications that should be displayed first for the user.

Returns:

  • (Array<Arkaan::Notification>)

    the unread notifications that should be displayed first for the user.



77
78
79
# File 'lib/arkaan/account.rb', line 77

def unread_notifications
  notifications.where(read: false)
end