Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2020-03-19 10:20:34 +0300
committerGitHub <noreply@github.com>2020-03-19 10:20:34 +0300
commitda8fda7d4d9660d0070ed2327a7ca4bca42f48d3 (patch)
treeb87cc0af867bad02efe6850cf81e8f607a8106bc /plugins/Login
parent47376fbccfa14ec07b67097357322e614ce50dd8 (diff)
Avoid update problem if token_auth table does not yet exist (#15706)
* Avoid update problem if token_auth table does not yet exist * move code to auth class
Diffstat (limited to 'plugins/Login')
-rw-r--r--plugins/Login/Auth.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/plugins/Login/Auth.php b/plugins/Login/Auth.php
index a196b48b15..00897b5d70 100644
--- a/plugins/Login/Auth.php
+++ b/plugins/Login/Auth.php
@@ -11,6 +11,7 @@ namespace Piwik\Plugins\Login;
use Piwik\AuthResult;
use Piwik\Auth\Password;
use Piwik\Date;
+use Piwik\DbHelper;
use Piwik\Piwik;
use Piwik\Plugins\UsersManager\Model;
use Piwik\Plugins\UsersManager\UsersManager;
@@ -54,12 +55,21 @@ class Auth implements \Piwik\Auth
*/
public function authenticate()
{
- if (!empty($this->hashedPassword)) {
- return $this->authenticateWithPassword($this->login, $this->getTokenAuthSecret());
- } elseif (is_null($this->login)) {
- return $this->authenticateWithToken($this->token_auth);
- } elseif (!empty($this->login)) {
- return $this->authenticateWithLoginAndToken($this->token_auth, $this->login);
+ try {
+ if (!empty($this->hashedPassword)) {
+ return $this->authenticateWithPassword($this->login, $this->getTokenAuthSecret());
+ } elseif (is_null($this->login)) {
+ return $this->authenticateWithToken($this->token_auth);
+ } elseif (!empty($this->login)) {
+ return $this->authenticateWithLoginAndToken($this->token_auth, $this->login);
+ }
+ } catch (\Zend_Db_Statement_Exception $e) {
+ // user_token_auth table might not yet exist when updating to Matomo 4
+ if (strpos($e->getMessage(), 'user_token_auth') && !DbHelper::tableExists('user_token_auth')) {
+ return new AuthResult(AuthResult::SUCCESS, 'anonymous', 'anonymous');
+ }
+
+ throw $e;
}
return new AuthResult(AuthResult::FAILURE, $this->login, $this->token_auth);