authhtpasswd : return the only detail available -> email
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3015 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -12,6 +12,9 @@ class authhtpasswd extends auth
|
||||
/** The .htpasswd file to use for authentication */
|
||||
public $htpasswdFile;
|
||||
|
||||
/** The details to return if the user is authenticated */
|
||||
private $details = null;
|
||||
|
||||
public function connect ()
|
||||
{
|
||||
if (! file_exists ($this->htpasswdFile))
|
||||
@@ -43,8 +46,12 @@ class authhtpasswd extends auth
|
||||
$cryptedPassword = substr (strstr ($line, ':'), 1);
|
||||
if ($user === $email)
|
||||
{
|
||||
if (substr ($cryptedPassword, 0, 6) === '$apr1$')
|
||||
throw new \Exception (dgettext ("domframework",
|
||||
"Invalid format of password"), 500);
|
||||
if (crypt ($password, $cryptedPassword) !== $cryptedPassword)
|
||||
throw new Exception ("Bad password for '$email'", 401);
|
||||
$this->details = array ("email"=>$email);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -54,9 +61,7 @@ class authhtpasswd extends auth
|
||||
/** Return all the parameters recorded for the authenticate user */
|
||||
public function getdetails ()
|
||||
{
|
||||
throw new Exception (dgettext ("domframework",
|
||||
"The details can't be provided by HTPasswd file"),
|
||||
404);
|
||||
return $this->details;
|
||||
}
|
||||
|
||||
/** Method to change the password
|
||||
|
||||
Reference in New Issue
Block a user