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:



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

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:



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

has_many :authorizations, class_name: 'Arkaan::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.



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

field :email, type: String

#firstnameString

Returns the first name of the user.

Returns:

  • (String)

    the first name of the user.



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

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.



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

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

#groupsArray<Arkaan::Permissions::Group>

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

Returns:



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

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:



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

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.



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

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.



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

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

#notificationsArray<Arkaan::Notification>

Returns the notifications linked to this user.

Returns:



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

embeds_many :notifications, class_name: 'Arkaan::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.



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

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.



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

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.



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

field :password_digest, type: String

#phonesArray<Arkaan::Phone>

Returns the phone numbers given by the user.

Returns:

  • (Array<Arkaan::Phone>)

    the phone numbers given by the user.



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

embeds_many :phones, class_name: 'Arkaan::Phone', inverse_of: :account

#servicesArray<Arkaan::Monitoring::Service>

Returns the services created by this user.

Returns:



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

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:



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

has_many :sessions, class_name: 'Arkaan::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.



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

field :username, type: String

#websocketsArray<Arkaan::Monitoring::Websocket>

Returns the websockets created by the owner of this account.

Returns:



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

has_many :websockets, class_name: 'Arkaan::Monitoring::Websocket', inverse_of: :creator

Instance Method Details

#read_notificationsArray<Arkaan::Notification>

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

Returns:

  • (Array<Arkaan::Notification>)

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



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

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.



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

def unread_notifications
  notifications.where(read: false)
end