Recuperacao de senha
This commit is contained in:
@@ -16,12 +16,11 @@
|
||||
|
||||
class Notifications < ActionMailer::Base
|
||||
|
||||
def forgot_password(to, login, pass, sent_at = Time.now)
|
||||
@subject = "Your password is ..."
|
||||
@body['login']=login
|
||||
@body['pass']=pass
|
||||
def forgot_password(to, key, sent_at = Time.now)
|
||||
@subject = "#{App.title} - Recuperar senha"
|
||||
@body['key'] = key
|
||||
@recipients = to
|
||||
@from = 'support@yourdomain.com'
|
||||
@from = "#{App.title} <#{App.webmaster_email}>"
|
||||
@sent_on = sent_at
|
||||
@headers = {}
|
||||
end
|
||||
|
||||
@@ -63,11 +63,10 @@ class User < ActiveRecord::Base
|
||||
end
|
||||
|
||||
# Gera uma nova senha, e a envia por email.
|
||||
def send_new_password
|
||||
new_pass = User.random_string(10)
|
||||
@password = @password_confirmation = new_pass
|
||||
save
|
||||
Notifications.deliver_forgot_password(self.email, self.login, new_pass)
|
||||
def generate_password_reset_key!
|
||||
update_attribute(:password_reset_key, User.random_string(30))
|
||||
save!
|
||||
Notifications.deliver_forgot_password(self.email, self.password_reset_key)
|
||||
end
|
||||
|
||||
def reset_login_key
|
||||
|
||||
Reference in New Issue
Block a user