CSRF protection in newmessage.php

darcs-hash:20080923031419-5ed1f-5435509496b882de27d4c3acca4697cc410ee7be.gz
This commit is contained in:
Evan Prodromou 2008-09-22 23:14:19 -04:00
parent 6e646570de
commit d2fb829296

View File

@ -38,6 +38,14 @@ class NewmessageAction extends Action {
$user = common_current_user(); $user = common_current_user();
assert($user); # XXX: maybe an error instead... assert($user); # XXX: maybe an error instead...
# 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;
}
$content = $this->trimmed('content'); $content = $this->trimmed('content');
$to = $this->trimmed('to'); $to = $this->trimmed('to');
@ -117,6 +125,8 @@ class NewmessageAction extends Action {
'type' => 'submit', 'type' => 'submit',
'value' => _('Send'))); 'value' => _('Send')));
common_hidden('token', common_session_token());
common_element_end('p'); common_element_end('p');
common_element_end('form'); common_element_end('form');
} }