Class: Adminpanel::User

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Base
Defined in:
app/models/adminpanel/user.rb

Constant Summary collapse

VALID_EMAIL_REGEX =
/\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.digest(token) ⇒ Object



92
93
94
# File 'app/models/adminpanel/user.rb', line 92

def User.digest(token)
  Digest::SHA1.hexdigest(token.to_s)
end

.display_nameObject



84
85
86
# File 'app/models/adminpanel/user.rb', line 84

def self.display_name
  'Usuario'
end

.form_attributesObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'app/models/adminpanel/user.rb', line 35

def self.form_attributes
  [
    {
      'name' => {
        'type' => 'text_field',
        'name' => 'Nombre',
        'label' => 'Nombre',
        'placeholder' => 'Nombre'
        }
    },
    {
      'email' => {
        'type' => 'text_field',
        'name' => 'Correo',
        'label' => 'Correo',
        'placeholder' => 'Correo'
      }
    },
    {
      'password' => {
        'type' => 'password_field',
        'name' => 'Contrasena',
        'label' => I18n.t('model.attributes.password'),
        'placeholder' => I18n.t('model.attributes.password'),
        'show' => 'false'
      }
    },
    {
      'password_confirmation' => {
        'type' => 'password_field',
        'name' => 'Confirmacion de contrasena',
        'placeholder' => I18n.t('model.attributes.password_confirmation'),
        'label' => I18n.t('model.attributes.password_confirmation'),
        'show' => 'false'
      }
    },
    {
      'group_id' => {
        'type' => 'belongs_to',
        'name' => 'Group',
        'model' => 'Adminpanel::Group',
        'remote_resource' => false,
        'placeholder' => I18n.t('model.attributes.group_id'),
        'label' => I18n.t('model.attributes.group_id')
      }
    },
  ]
end

.iconObject



96
97
98
# File 'app/models/adminpanel/user.rb', line 96

def self.icon
  'user'
end

.new_remember_tokenObject



88
89
90
# File 'app/models/adminpanel/user.rb', line 88

def User.new_remember_token
  SecureRandom.urlsafe_base64
end

Instance Method Details

#has_role?(role_sym) ⇒ Boolean

Returns:

  • (Boolean)


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

def has_role?(role_sym)
  roles.any? { |r| r.name.underscore.to_sym == role_sym }
end