Class: Core::Models::Account

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::SecurePassword, Concerns::Enumerable, Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/core/models/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

#applications ⇒ Array<Core::Models::OAuth::Application] the applications this user has created and owns.

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

Returns:



45
# File 'lib/core/models/account.rb', line 45

has_many :applications, class_name: 'Core::Models::OAuth::Application', inverse_of: :creator

#authorizations ⇒ Array<Core::Models::OAuth::Authorization>

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

Returns:



48
# File 'lib/core/models/account.rb', line 48

has_many :authorizations, class_name: 'Core::Models::OAuth::Authorization', inverse_of: :account

#email ⇒ String

Returns the email address of the user, useful to contact them ; it must be given, unique, and have an email format.

Returns:

  • (String) —

    the email address of the user, useful to contact them ; it must be given, unique, and have an email format.



25
# File 'lib/core/models/account.rb', line 25

field :email, type: String

#firstname ⇒ String

Returns the first name of the user.

Returns:

  • (String) —

    the first name of the user.



22
# File 'lib/core/models/account.rb', line 22

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

#gender ⇒ Symbol

Returns the way you prefer the application to gender you.

Returns:

  • (Symbol) —

    the way you prefer the application to gender you.



31
# File 'lib/core/models/account.rb', line 31

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

#groups ⇒ Array<Core::Models::Permissions::Group>

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

Returns:



41
# File 'lib/core/models/account.rb', line 41

has_and_belongs_to_many :groups, class_name: 'Core::Models::Permissions::Group', inverse_of: :accounts

#invitations ⇒ Array<Core::Models::Campaigns::Invitation>

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

Returns:



57
# File 'lib/core/models/account.rb', line 57

has_many :invitations, class_name: 'Core::Models::Campaigns::Invitation', inverse_of: :account

#language ⇒ Symbol

Returns the language preferred by this user.

Returns:

  • (Symbol) —

    the language preferred by this user.



28
# File 'lib/core/models/account.rb', line 28

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

#lastname ⇒ String

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

Returns:

  • (String) —

    the last name (family name) of the user.



19
# File 'lib/core/models/account.rb', line 19

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

#messages ⇒ Array<Core::Models::Chatrooms::Messages>

Returns all the messages ever sent by the user.

Returns:

  • (Array<Core::Models::Chatrooms::Messages>) —

    all the messages ever sent by the user.



66
# File 'lib/core/models/account.rb', line 66

has_many :messages, class_name: 'Core::Models::Chatrooms::Message', inverse_of: :account

#notifications ⇒ Array<Core::Models::Notification>

Returns the notifications linked to this user.

Returns:



72
# File 'lib/core/models/account.rb', line 72

embeds_many :notifications, class_name: 'Core::Models::Notification', inverse_of: :account

#password=(value) ⇒ String (writeonly)

Returns password, in clear, of the user ; do not attempt to get the value, just set it when changing the password.

Returns:

  • (String) —

    password, in clear, of the user ; do not attempt to get the value, just set it when changing the password.



37
# File 'lib/core/models/account.rb', line 37

has_secure_password validations: false

#password_confirmation=(value) ⇒ String (writeonly)

Returns the confirmation of the password, do not get, just set it ; it must be the same as the password.

Returns:

  • (String) —

    the confirmation of the password, do not get, just set it ; it must be the same as the password.



37
# File 'lib/core/models/account.rb', line 37

has_secure_password validations: false

#password_digest ⇒ String (readonly)

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

Returns:

  • (String) —

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



16
# File 'lib/core/models/account.rb', line 16

field :password_digest, type: String

#permissions ⇒ Array<Core::Models::Files::Permission>

Returns the file access permissions granted to this account.

Returns:



63
# File 'lib/core/models/account.rb', line 63

has_many :permissions, class_name: 'Core::Models::Files::Permission', inverse_of: :account

#services ⇒ Array<Core::Models::Monitoring::Service>

Returns the services created by this user.

Returns:



51
# File 'lib/core/models/account.rb', line 51

has_many :services, class_name: 'Core::Models::Monitoring::Service', inverse_of: :creator

#sessions ⇒ Array<Core::Models::Authentication::Session>

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

Returns:



54
# File 'lib/core/models/account.rb', line 54

has_many :sessions, class_name: 'Core::Models::Authentication::Session', inverse_of: :account

#username ⇒ String

Returns the nickname the user chose at subscription, must be given, unique, and 6 or more characters long.

Returns:

  • (String) —

    the nickname the user chose at subscription, must be given, unique, and 6 or more characters long.



13
# File 'lib/core/models/account.rb', line 13

field :username, type: String

Instance Method Details

#read_notifications ⇒ Array<Core::Models::Notification>

Returns the notifications already read, less important to display than the unread ones.

Returns:



80
81
82
# File 'lib/core/models/account.rb', line 80

def read_notifications
  notifications.where(read: true)
end

#unread_notifications ⇒ Array<Core::Models::Notification>

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

Returns:



75
76
77
# File 'lib/core/models/account.rb', line 75

def unread_notifications
  notifications.where(read: false)
end