Bug 253788 - last.fm will not log in, but if previously logged in works fine, in Amarok 2.3.2 onwards
Summary: last.fm will not log in, but if previously logged in works fine, in Amarok 2....
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Services/Last.fm (show other bugs)
Version: 2.3.2
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: 2.4.0
Assignee: Amarok Developers
URL:
Keywords:
: 253923 254006 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-10-10 22:59 UTC by Sam Lade
Modified: 2010-10-15 11:43 UTC (History)
9 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.4
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Lade 2010-10-10 22:59:07 UTC
Version:           2.3.2 (using KDE 4.5.2) 
OS:                Linux

Fails to generate last.fm login cookie/token from tag 2.3.2 onwards (present in both 2.3.2 release and latest 2.4 git). From discussion in #amarok, it is believed this was introduced in git about two weeks before 2.3.2 was tagged.
If a last.fm login cookie (i.e., a working last.fm login) is present from prior to this change, scrobbling and loving will work fine (although the "test login" button still shows failed).
If the cookie is not present, a new one will not be generated, so last.fm login and subsequently scrobbling etc fail.

Originally reported in #amarok, and tested with the method listed below. Downgrading to 2.3.1, logging into last.fm (which works, as does the test login button), and then moving back up to latest successfully restores last.fm connectivity.

Reproducible: Always

Steps to Reproduce:
1) Change or remove last.fm login details
2) Restore last.fm login details
3) Play music

Actual Results:  
Scrobbling and loving tracks fails; toast notification in the corner of the window notes problems with last.fm connection

Expected Results:  
Scrobbles correctly
Comment 1 Paulo Dias 2010-10-10 23:01:08 UTC
same here, amarok git from today, i was involved in the discussion of this bug in #amarok, so feel free to ask for patch testing.
Comment 2 Myriam Schweingruber 2010-10-12 16:17:12 UTC
Confirmed by comment #1
Comment 3 Ian Whyman (thev00d00) 2010-10-12 20:01:55 UTC
Confirmed here too
Comment 4 Rick W. Chen 2010-10-15 03:53:10 UTC
commit d01e51eee853596aa04e377253c6f3d83b6483c3
Author: Rick W. Chen <stuffcorpse@archlinux.us>
Date:   Fri Oct 15 14:49:22 2010 +1300

    Fix last.fm auth failure introduced by ec210e0cf3119818a1d359885b77f6ef21a86cea
    
    BUG: 253788
    CCMAIL: kretschmann@kde.org

diff --git a/src/services/lastfm/LastFmService.cpp b/src/services/lastfm/LastFmService.cpp
index e039cea..05bb948 100644
--- a/src/services/lastfm/LastFmService.cpp
+++ b/src/services/lastfm/LastFmService.cpp
@@ -251,7 +251,7 @@ LastFmService::init()
 
     debug() << "username:" << QString( QUrl::toPercentEncoding( lastfm::ws::Username ) );
 
-    const QString authToken = md5( m_userName.toUtf8() ) + md5( password.toUtf8() );
+    const QString authToken = md5( ( m_userName + md5( password.toUtf8() ) ).toUtf8() );
 
     // now authenticate w/ last.fm and get our session key if we don't have one
     if( sessionKey.isEmpty() )
diff --git a/src/services/lastfm/LastFmServiceSettings.cpp b/src/services/lastfm/LastFmServiceSettings.cpp
index 07eb64b..4b51ba1 100644
--- a/src/services/lastfm/LastFmServiceSettings.cpp
+++ b/src/services/lastfm/LastFmServiceSettings.cpp
@@ -14,6 +14,8 @@
  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
  ****************************************************************************************/
 
+#define DEBUG_PREFIX "LastFmServiceSettings"
+
 #include "LastFmServiceSettings.h"
 
 #include "core/support/Amarok.h"
@@ -112,8 +114,8 @@ LastFmServiceSettings::testLogin()
 
     debug() << "username:" << QString( QUrl::toPercentEncoding( lastfm::ws::Username ) );
 
-    const QString authToken = QString( md5( m_configDialog->kcfg_ScrobblerUsername->text().toUtf8() ) +
-                                       md5( m_configDialog->kcfg_ScrobblerPassword->text().toUtf8() ) );
+    const QString authToken = md5( ( m_configDialog->kcfg_ScrobblerUsername->text() +
+                                     md5( m_configDialog->kcfg_ScrobblerPassword->text().toUtf8() ) ).toUtf8() );
 
     // now authenticate w/ last.fm and get our session key
     QMap<QString, QString> query;
Comment 5 Myriam Schweingruber 2010-10-15 11:42:37 UTC
*** Bug 253923 has been marked as a duplicate of this bug. ***
Comment 6 Myriam Schweingruber 2010-10-15 11:43:30 UTC
*** Bug 254006 has been marked as a duplicate of this bug. ***