1
/***************************************************************************
2
* Copyright (C) 2005 - 2007 by *
3
* Max Howell, Last.fm Ltd <max@last.fm> *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. *
19
***************************************************************************/
21
#include "UnicornCommon.h"
26
VerifyUserRequest::VerifyUserRequest()
27
: Request( TypeVerifyUser, "VerifyUser" ),
28
m_userAuthCode( AUTH_ERROR )
35
VerifyUserRequest::start()
39
QString const time = QString::number( now );
41
// Concatenate pw hash with time
42
QString auth = m_passwordMd5 + time;
43
QString authLower = m_passwordMd5Lower + time;
45
// Hash the concatenated string to create auth code
46
QString authMd5 = UnicornUtils::md5Digest( auth.toUtf8() );
47
QString authMd5Lower = UnicornUtils::md5Digest( authLower.toUtf8() );
49
QString const path = "/ass/pwcheck.php?"
50
"time=" + QString( QUrl::toPercentEncoding( time ) ) +
51
"&username=" + QString( QUrl::toPercentEncoding( m_username ) ) +
53
"&auth2=" + authMd5Lower +
56
+ QString( QUrl::toPercentEncoding( UnicornUtils::findDefaultPlayer() ) )
65
VerifyUserRequest::success( QByteArray data )
67
QString response = data;
68
response = response.trimmed();
70
//TODO mxcl do in baseclass?
71
LOG( 4, "Verify response: " << response << "\n" );
73
m_bootStrapCode = response.contains( "BOOTSTRAP" )
77
if (response.contains( "OK2" ))
78
m_userAuthCode = AUTH_OK_LOWER;
79
else if (response.contains( "OK" ))
80
m_userAuthCode = AUTH_OK;
81
else if (response.contains( "INVALIDUSER" ))
82
m_userAuthCode = AUTH_BADUSER;
83
else if (response.contains( "BADPASSWORD" ))
84
m_userAuthCode = AUTH_BADPASS;
86
m_userAuthCode = AUTH_ERROR;