Module: Concerns::User::AuthDefinitions

Defined in:
app/models/faalis/concerns/user/auth_definitions.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) admin?

Returns:

  • (Boolean)


32
33
34
35
# File 'app/models/faalis/concerns/user/auth_definitions.rb', line 32

def admin?
  # TODO: Find a better way to 'admin?'
  groups.where(role: 'admin').exists?
end

- (Boolean) confirmation_required?

Confirmation not required when using omniauth

Returns:

  • (Boolean)


38
39
40
# File 'app/models/faalis/concerns/user/auth_definitions.rb', line 38

def confirmation_required?
  super && identities.empty?
end

- (Object) full_name



28
29
30
# File 'app/models/faalis/concerns/user/auth_definitions.rb', line 28

def full_name
  name
end

- (Object) name



19
20
21
22
23
24
25
26
# File 'app/models/faalis/concerns/user/auth_definitions.rb', line 19

def name
  if first_name or last_name
    "#{first_name} #{last_name}"
  else
    email
  end

end

- (Boolean) password_required?

Omniauth users does not need password

Returns:

  • (Boolean)


51
52
53
54
55
56
57
58
# File 'app/models/faalis/concerns/user/auth_definitions.rb', line 51

def password_required?
  # TODO: nil? is not suitable for here we should use empty? or blink?
  if Devise.omniauth_configs.any?
    return (provider.nil? || password.nil?) && super
  else
    password.nil? && super
  end
end

- (Object) update_with_password(params, *options)



42
43
44
45
46
47
48
# File 'app/models/faalis/concerns/user/auth_definitions.rb', line 42

def update_with_password(params, *options)
  if encrypted_password.blank?
    update_attributes(params, *options)
  else
    super
  end
end