CSRF protection in recoverpassword

darcs-hash:20080829052824-7b5ce-39a8fd299b7a85793ad7a19fe00c93813ca882b6.gz
This commit is contained in:
Zach Copley 2008-08-29 01:28:24 -04:00
parent 98e941753b
commit 47726844a0

View File

@ -176,6 +176,7 @@ class RecoverpasswordAction extends Action {
common_element_start('form', array('method' => 'post', common_element_start('form', array('method' => 'post',
'id' => 'recoverpassword', 'id' => 'recoverpassword',
'action' => common_local_url('recoverpassword'))); 'action' => common_local_url('recoverpassword')));
common_hidden('token', common_session_token());
common_password('newpassword', _('New password'), common_password('newpassword', _('New password'),
_('6 or more characters, and don\'t forget it!')); _('6 or more characters, and don\'t forget it!'));
common_password('confirm', _('Confirm'), common_password('confirm', _('Confirm'),
@ -270,6 +271,13 @@ class RecoverpasswordAction extends Action {
function reset_password() { function reset_password() {
# CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->show_form(_('There was a problem with your session token. Try again, please.'));
return;
}
$user = $this->get_temp_user(); $user = $this->get_temp_user();
if (!$user) { if (!$user) {