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

#applicationsArray<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:



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

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

#authorizationsArray<Core::Models::OAuth::Authorization>

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

Returns:



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

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

#emailString

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.



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

field :email, type: String

#firstnameString

Returns the first name of the user.

Returns:

  • (String)

    the first name of the user.



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

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.



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

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

#invitationsArray<Core::Models::Campaigns::Invitation>

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

Returns:



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

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

#languageSymbol

Returns the language preferred by this user.

Returns:

  • (Symbol)

    the language preferred by this user.



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

enum_field :language, [: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.



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

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

#messagesArray<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.



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

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

#notificationsArray<Core::Models::Notification>

Returns the notifications linked to this user.

Returns:



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

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.



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

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.



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

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.



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

field :password_digest, type: String

#permissionsArray<Core::Models::Files::Permission>

Returns the file access permissions granted to this account.

Returns:



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

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

#sessionsArray<Core::Models::Authentication::Session>

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

Returns:



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

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

#usernameString

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.



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

field :username, type: String

Instance Method Details

#read_notificationsArray<Core::Models::Notification>

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

Returns:



73
74
75
# File 'lib/core/models/account.rb', line 73

def read_notifications
  notifications.where(read: true)
end

#unread_notificationsArray<Core::Models::Notification>

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

Returns:



68
69
70
# File 'lib/core/models/account.rb', line 68

def unread_notifications
  notifications.where(read: false)
end