Fix Cross Site Request Forgery on theme selection by using token
This commit is contained in:
parent
916f7b7a16
commit
1b4eeb386a
2 changed files with 18 additions and 5 deletions
|
@ -21,10 +21,23 @@ checkRole(array('admin'));
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Main after POST
|
// Main after POST
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
$themeDirectory = $layout['parameters'];
|
$parameters = explode("/", $layout['parameters']);
|
||||||
|
if(count($parameters)==2) {
|
||||||
|
$themeDirectory = $parameters[0];
|
||||||
|
|
||||||
// Activate theme
|
// Verify CSRF Token
|
||||||
activateTheme($themeDirectory);
|
$token = Sanitize::html($parameters[1]);
|
||||||
|
if (!$security->validateTokenCSRF($token)) {
|
||||||
|
Log::set(__FILE__.LOG_SEP.'Error occurred when trying to validate the tokenCSRF.', ALERT_STATUS_FAIL);
|
||||||
|
Log::set(__FILE__.LOG_SEP.'Token in install theme ['.$token.']', ALERT_STATUS_FAIL);
|
||||||
|
|
||||||
|
Session::destroy();
|
||||||
|
Redirect::page('login');
|
||||||
|
} else {
|
||||||
|
// Activate theme
|
||||||
|
activateTheme($themeDirectory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Redirect
|
// Redirect
|
||||||
Redirect::page('themes');
|
Redirect::page('themes');
|
||||||
|
|
|
@ -24,7 +24,7 @@ foreach ($themes as $theme) {
|
||||||
';
|
';
|
||||||
|
|
||||||
if ($theme['dirname']!=$site->theme()) {
|
if ($theme['dirname']!=$site->theme()) {
|
||||||
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'install-theme/'.$theme['dirname'].'">'.$L->g('Activate').'</a>';
|
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'install-theme/'.$theme['dirname'].'/'.$security->getTokenCSRF().'">'.$L->g('Activate').'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
@ -50,4 +50,4 @@ foreach ($themes as $theme) {
|
||||||
echo '
|
echo '
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
';
|
';
|
||||||
|
|
Loading…
Add table
Reference in a new issue