CSRF protection in twittersettings.php

darcs-hash:20080829045724-7b5ce-66fdc5e54155012e41eb09c6a41bc94619bf520f.gz
This commit is contained in:
Zach Copley 2008-08-29 00:57:24 -04:00
parent a637f36214
commit 6c4dc071bf
1 changed files with 9 additions and 0 deletions

View File

@ -43,6 +43,7 @@ class TwittersettingsAction extends SettingsAction {
'id' => 'twittersettings',
'action' =>
common_local_url('twittersettings')));
common_hidden('token', common_session_token());
if ($fuser) {
common_element_start('p');
@ -83,6 +84,14 @@ class TwittersettingsAction extends SettingsAction {
}
function handle_post() {
# 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;
}
if ($this->arg('save')) {
$this->save_preferences();
} else if ($this->arg('add')) {