Class: AuthEng::User

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

Instance Method Summary collapse

Instance Method Details

#attempt_set_password(params) ⇒ Object

new function to set the password without knowing the current password used in our confirmation controller.



20
21
22
23
24
25
# File 'app/models/auth_eng/user.rb', line 20

def attempt_set_password(params)
  p = {}
  p[:password] = params[:password]
  p[:password_confirmation] = params[:password_confirmation]
  update_attributes(p)
end

#has_no_password?Boolean

new function to return whether a password has been set

Returns:

  • (Boolean)


28
29
30
# File 'app/models/auth_eng/user.rb', line 28

def has_no_password?
  self.encrypted_password.blank?
end

#only_if_unconfirmedObject



15
16
17
# File 'app/models/auth_eng/user.rb', line 15

def only_if_unconfirmed
  pending_any_confirmation {yield}
end

#password_required?Boolean

Password is required if it is being set, but not for new records

Returns:

  • (Boolean)


33
34
35
36
37
38
39
# File 'app/models/auth_eng/user.rb', line 33

def password_required?
  if !persisted? 
    false
  else
    !password.nil? || !password_confirmation.nil?
  end
end

#send_on_create_confirmation_instructionsObject



41
42
43
# File 'app/models/auth_eng/user.rb', line 41

def send_on_create_confirmation_instructions
  Devise::Mailer.delay.confirmation_instructions(self)
end