Skip to content

Commit

Permalink
Fix #104. Filter user id literal for comparison.
Browse files Browse the repository at this point in the history
  • Loading branch information
white-gecko committed Apr 29, 2016
1 parent 40c1caa commit 1e1253a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions library/Erfurt/Auth/Identity/Recovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ public function validateUser($identity)
$query->addFrom($config->ac->modelUri);
$query->setSelectClause('SELECT *');
$query->setWherePart(
'{ ?user <' . $config->ac->user->name . '> "' . $identity . '" .
OPTIONAL { ?user <' . $config->ac->user->mail . '> ?mail . } }'
'{ ?user <' . $config->ac->user->name . '> ?identity .
OPTIONAL { ?user <' . $config->ac->user->mail . '> ?mail . }
FILTER (STR(?identity) = "' . $identity . '")
}'
);

$resultUser = $store->sparqlQuery($query, array('use_ac' => false));
Expand All @@ -85,7 +87,7 @@ public function validateUser($identity)
$username = $resultMail[0]['name'];
$mailAddr = $identity;
} else {

throw new Erfurt_Auth_Identity_Exception('Unknown user identifier.');
}

Expand Down Expand Up @@ -201,7 +203,7 @@ public function validateHash($hash)
if ( !empty($resultUser) ) {
return $resultUser[0]['user'];
} else {

throw new Erfurt_Auth_Identity_Exception('Invalid recovery session identifier.');
}

Expand All @@ -222,17 +224,17 @@ public function resetPassword( $hash, $password1, $password2)
$ret = false;

if ($password1 !== $password2) {

throw new Erfurt_Auth_Identity_Exception('Passwords do not match.');
} else if (strlen($password1) < 5) {

throw new Erfurt_Auth_Identity_Exception('Password needs at least 5 characters.');
} else if (
isset($actionConfig['passregexp']) &&
$actionConfig['passregexp'] != '' &&
!@preg_match($actionConfig['passregexp'], $password1)
) {

throw new Erfurt_Auth_Identity_Exception('Password does not match regular expression set in system configuration');
} else {
// Set new password.
Expand Down

0 comments on commit 1e1253a

Please sign in to comment.