From f86691a3218c3669fbfd32da0fa3fa54a1cd006d Mon Sep 17 00:00:00 2001 From: mattpiwik <matthieu.aubry@gmail.com> Date: Mon, 12 Jul 2010 09:05:27 +0000 Subject: [PATCH] Fixes #1472. Super user password reset will fail with message if config file not writable. git-svn-id: http://dev.piwik.org/svn/trunk@2473 59fd770c-687e-43c8-a1e3-f5a4ff64c105 --- plugins/Login/Controller.php | 13 ++++++++----- plugins/Login/templates/passwordchanged.tpl | 1 - tests/integration/Main.test.php | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/Login/Controller.php b/plugins/Login/Controller.php index ceb7204a72..65e12e32b4 100644 --- a/plugins/Login/Controller.php +++ b/plugins/Login/Controller.php @@ -199,13 +199,12 @@ class Piwik_Login_Controller extends Piwik_Controller $mail = new Piwik_Mail(); $mail->addTo($email, $login); $mail->setSubject(Piwik_Translate('Login_MailTopicPasswordRecovery')); - $mail->setBodyText( - str_replace( + $bodyText = str_replace( '\n', "\n", sprintf(Piwik_Translate('Login_MailPasswordRecoveryBody'), $login, $ip, $url, $resetToken) - ) . "\n" - ); + ) . "\n"; + $mail->setBodyText($bodyText); $piwikHost = $_SERVER['HTTP_HOST']; if(strlen($piwikHost) == 0) @@ -279,10 +278,15 @@ class Piwik_Login_Controller extends Piwik_Controller return Piwik_Translate('Login_InvalidOrExpiredToken'); } + $view = Piwik_View::factory('passwordchanged'); try { if( $user['email'] == Zend_Registry::get('config')->superuser->email ) { + if(!Zend_Registry::get('config')->isFileWritable()) + { + throw new Exception(Piwik_Translate('General_ConfigFileIsNotWritable', array("(config/config.ini.php)","<br/>"))); + } $user['password'] = md5($password); Zend_Registry::get('config')->superuser = $user; } @@ -296,7 +300,6 @@ class Piwik_Login_Controller extends Piwik_Controller $view->ErrorString = $e->getMessage(); } - $view = Piwik_View::factory('passwordchanged'); $view->linkTitle = Piwik::getRandomTitle(); echo $view->render(); diff --git a/plugins/Login/templates/passwordchanged.tpl b/plugins/Login/templates/passwordchanged.tpl index 5337abc2c2..bc55d94f15 100644 --- a/plugins/Login/templates/passwordchanged.tpl +++ b/plugins/Login/templates/passwordchanged.tpl @@ -4,7 +4,6 @@ {if isset($ErrorString)} <div id="login_error"><strong>{'General_Error'|translate}</strong>: {$ErrorString}<br /> - {'Login_ContactAdmin'|translate} </div> {else} <p class="message"> diff --git a/tests/integration/Main.test.php b/tests/integration/Main.test.php index 4075438608..6a0c6b0f86 100644 --- a/tests/integration/Main.test.php +++ b/tests/integration/Main.test.php @@ -16,7 +16,7 @@ require_once PIWIK_INCLUDE_PATH . '/tests/integration/Integration.php'; * * The test calls the Piwik tracker with known sets of data, expected errors, * and can test the output of the tracker beacon, as well as calling - * all API functions, and Widgets, and compare their XML/HTML output with the 'expected output'. + * all API functions and compare their HTML output with the 'expected output'. * * If an algorithm changes in the Tracker or in the Archiving, tests can easily be run to check that * the output changes as expected (eg. More accurate browser detection, adding a new metric in the @@ -74,7 +74,7 @@ class Test_Piwik_Integration_Main extends Test_Integration $t->setIp($excludedIpBis); $this->checkResponse($t->doTrackPageView('visit from IP globally excluded')); - + // this will output empty XML result sets as no visit was tracked $this->callGetApiCompareOutput(__FUNCTION__, 'xml', $idSite, $dateTime); } -- GitLab