Class: Cms::User

Inherits:
PersistentUser show all
Includes:
Devise::Models::Recoverable, Devise::Models::Validatable
Defined in:
app/models/cms/user.rb

Overview

Represents a CMS users that is managed through the CMS UI.

Direct Known Subclasses

GuestUser

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PersistentUser

able_to_edit_or_publish_content, #active_for_authentication?, #cas_extra_attributes=, current, current=, #disable, #disable!, #enable, #enable!, #expired?, #expires_at_formatted, #full_name, #group_codes, #group_codes=, guest, #guest?, #password_changeable?

Methods included from DefaultAccessible

#non_permitted_params, #permitted_params

Class Method Details

.change_password(login, new_password) ⇒ Object

Change a given user’s password.

Parameters:

  • login (String)
  • new_password (String)


13
14
15
# File 'app/models/cms/user.rb', line 13

def change_password(, new_password)
  ().change_password(new_password)
end

.permitted_paramsObject



17
18
19
# File 'app/models/cms/user.rb', line 17

def permitted_params
  super + [:password, :password_confirmation]
end

Instance Method Details

#change_password(new_password) ⇒ Object

Change this User’s password to a new value.



31
32
33
34
# File 'app/models/cms/user.rb', line 31

def change_password(new_password)
  update(:password => new_password, :password_confirmation => new_password)
  new_password
end

#new_passwordString

Generate a new random password for this user.

Returns:

  • (String)

    The newly generated and assigned password



24
25
26
27
28
# File 'app/models/cms/user.rb', line 24

def new_password
  pwd = SecureRandom.hex(4)
  change_password(pwd)
  pwd
end

#sourceObject

By default, Users are coming from the the CMS database (cms_users). All Cms::User class have have the same source.



39
40
41
# File 'app/models/cms/user.rb', line 39

def source
  "CMS Users"
end