Recuperacao de senha

This commit is contained in:
2008-04-19 19:14:47 -03:00
parent 2dc4416dad
commit 0695c44b21
11 changed files with 109 additions and 28 deletions

View File

@@ -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

View File

@@ -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