]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
CSRF protection in twittersettings.php
authorZach Copley <zach@controlyourself.ca>
Fri, 29 Aug 2008 04:57:24 +0000 (00:57 -0400)
committerZach Copley <zach@controlyourself.ca>
Fri, 29 Aug 2008 04:57:24 +0000 (00:57 -0400)
darcs-hash:20080829045724-7b5ce-66fdc5e54155012e41eb09c6a41bc94619bf520f.gz

actions/twittersettings.php

index 592c9347f6d6994ceb50e28ddaf3249735319fe3..dac0ce2000767d1ebdc02e086681f6c07fa78fcd 100644 (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')) {