Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Accept a hashed password on Auth::getMobileSession #8

Merged
merged 1 commit into from

2 participants

@itavero

In some scenarios you might all ready have a hashed password and you don't want it to be hashed again within the method. I've added an additional, optional parameter to the Auth::getMobileSession method. When set to false it will not hash the password.
It defaults to true, to make sure it's backwards compatible.

PS: I know this PR is long overdue ;)

@itavero itavero Made it possible to pass a hashed password into Auth::getMobileSession
By default the behavior of Auth::getMobileSession will be the same as
before, but if you set the 3rd argument to false it will not MD5
$password in the request. This way it is possible to md5 this yourself
if you have a reason to do this (I have one, that's why I added this).
;)
d668537
@itavero

Ping @fxb

@fxb fxb merged commit 9c5e617 into fxb:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 4, 2011
  1. @itavero

    Made it possible to pass a hashed password into Auth::getMobileSession

    itavero authored
    By default the behavior of Auth::getMobileSession will be the same as
    before, but if you set the 3rd argument to false it will not MD5
    $password in the request. This way it is possible to md5 this yourself
    if you have a reason to do this (I have one, that's why I added this).
    ;)
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/Auth.php
View
5 src/Auth.php
@@ -34,16 +34,17 @@ public static function getApiSignature(array $params, $apiSecret){
*
* @param string $username The last.fm username. (Required)
* @param string $password The last.fm password. (Required)
+ * @param bool $apply_md5 Set to false if the supplied password has already been hashed. (Optional)
* @return Session A Session object.
*
* @static
* @access public
* @throws Error
*/
- public static function getMobileSession($username, $password){
+ public static function getMobileSession($username, $password, $apply_md5 = true){
$xml = CallerFactory::getDefaultCaller()->signedCall('auth.getMobileSession', array(
'username' => $username,
- 'authToken' => md5($username . md5($password))
+ 'authToken' => md5($username . (($apply_md5) ? md5($password) : $password))
));
return Session::fromSimpleXMLElement($xml);
Something went wrong with that request. Please try again.