@avkarenow opened this Issue on March 8th 2016

Hello,

logme doesn't work with token_auth since 2.15.0 Piwik version.

I did a few tests with plugins/Login/Auth.php file:
URL: https://my_piwikl/index.php?module=Login&action=logme&login=my_login&password=my_md5
with this changes:

          if (!empty($this->hashedPassword)) { // favor authenticating by password
`+            echo "1\n";`
`+            echo $this->token_auth."\n";`
`+            echo $this->login."\n";`
`+            echo $this->getTokenAuthSecret()."\n";`
             return $this->authenticateWithPassword($this->login, $this->getTokenAuthSecret());
         } elseif (is_null($this->login)) {
`+            echo "2\n";`
             return $this->authenticateWithToken($this->token_auth);
         } elseif (!empty($this->login)) {
`+            echo "3\n";`
`+            echo $this->token_auth."\n";`
`+            echo $this->login."\n";`
`+            echo $this->getTokenAuthSecret()."\n";`
             return $this->authenticateWithTokenOrHashToken($this->token_auth, $this->login);

Result is:
3
anonymous
anonymous
1
anonymous
my_login
my_md5

So, code after 2.15.0 didn't use a authenticateWithTokenOrHashToken() to auth...
Next I changed function to use authenticateWithTokenOrHashToken():

@@ -50,7 +50,7 @@
     public function authenticate()
     {
         if (!empty($this->hashedPassword)) { // favor authenticating by password
`-            return $this->authenticateWithPassword($this->login, $this->getTokenAuthSecret());`
`+            return $this->authenticateWithTokenOrHashToken($this->getTokenAuthSecret(), $this->login);`
         } elseif (is_null($this->login)) {
             return $this->authenticateWithToken($this->token_auth);
         } elseif (!empty($this->login)) {

And now I can login using logme and token_auth again.

@quba commented on March 8th 2016 Contributor

It doesn't work for superuser account. Maybe that's the reason? It's so by design.

@avkarenow commented on March 8th 2016

It's normal user account, not superuser.

@tsteur commented on March 8th 2016 Owner

I tried to reproduce with 2.16.0 but couldn't. Works fine for me. Likely it was fixed recently, can you update to latest Piwik version?

This Issue was closed on March 8th 2016
Powered by GitHub Issue Mirror