Description:
MERGED bug fix on user password recovery from ytopc branch (change set 402:403)
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@404 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r191:976e2beba418 - - 1 file changed: 2 inserted, 1 deleted
@@ -94,12 +94,13 | |||||
|
94 | if user |
|
94 | if user |
|
95 | last_updated_time = user.updated_at || user.created_at || (Time.now.gmtime - 1.hour) |
|
95 | last_updated_time = user.updated_at || user.created_at || (Time.now.gmtime - 1.hour) |
|
96 | if last_updated_time > Time.now.gmtime - 5.minutes |
|
96 | if last_updated_time > Time.now.gmtime - 5.minutes |
|
97 | flash[:notice] = 'The account has recently created or new password has recently been requested. Please wait for 5 minutes' |
|
97 | flash[:notice] = 'The account has recently created or new password has recently been requested. Please wait for 5 minutes' |
|
98 | else |
|
98 | else |
|
99 | user.password = user.password_confirmation = User.random_password |
|
99 | user.password = user.password_confirmation = User.random_password |
|
|
100 | + user.save | ||
|
100 | send_new_password_email(user) |
|
101 | send_new_password_email(user) |
|
101 | flash[:notice] = 'New password has been mailed to you.' |
|
102 | flash[:notice] = 'New password has been mailed to you.' |
|
102 | end |
|
103 | end |
|
103 | else |
|
104 | else |
|
104 | flash[:notice] = I18n.t 'registration.password_retrieval.no_email' |
|
105 | flash[:notice] = I18n.t 'registration.password_retrieval.no_email' |
|
105 | end |
|
106 | end |
@@ -153,13 +154,13 | |||||
|
153 | def send_new_password_email(user) |
|
154 | def send_new_password_email(user) |
|
154 | contest_name = Configuration['contest.name'] |
|
155 | contest_name = Configuration['contest.name'] |
|
155 | admin_email = Configuration['system.admin_email'] |
|
156 | admin_email = Configuration['system.admin_email'] |
|
156 | mail = TMail::Mail.new |
|
157 | mail = TMail::Mail.new |
|
157 | mail.to = user.email |
|
158 | mail.to = user.email |
|
158 | mail.from = Configuration['system.online_registration.from'] |
|
159 | mail.from = Configuration['system.online_registration.from'] |
|
159 |
- mail.subject = "[#{contest_name}] |
|
160 | + mail.subject = "[#{contest_name}] Password recovery" |
|
160 | mail.body = t('registration.password_retrieval.email_body', { |
|
161 | mail.body = t('registration.password_retrieval.email_body', { |
|
161 | :full_name => user.full_name, |
|
162 | :full_name => user.full_name, |
|
162 | :contest_name => contest_name, |
|
163 | :contest_name => contest_name, |
|
163 | :login => user.login, |
|
164 | :login => user.login, |
|
164 | :password => user.password, |
|
165 | :password => user.password, |
|
165 | :admin_email => admin_email |
|
166 | :admin_email => admin_email |
You need to be logged in to leave comments.
Login now