Update gettext : add spaces
DomCi : remove line too longs on all the files git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5280 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
38
authsql.php
38
authsql.php
@@ -43,25 +43,25 @@ class authsql extends auth
|
||||
public function connect ()
|
||||
{
|
||||
if (! function_exists ("openssl_random_pseudo_bytes"))
|
||||
throw new Exception (dgettext("domframework",
|
||||
throw new Exception (dgettext ("domframework",
|
||||
"No PHP support for openssl_random_pseudo_bytes"),
|
||||
500);
|
||||
$this->db = new dblayer ($this->dsn, $this->username, $this->password,
|
||||
$this->driver_options);
|
||||
if ($this->table === null)
|
||||
throw new Exception (dgettext("domframework","No SQL table defined"),
|
||||
throw new Exception (dgettext ("domframework","No SQL table defined"),
|
||||
500);
|
||||
if ($this->fieldIdentifier === null)
|
||||
throw new Exception (dgettext("domframework",
|
||||
throw new Exception (dgettext ("domframework",
|
||||
"No fieldIdentifier defined"), 500);
|
||||
if ($this->fieldPassword === null)
|
||||
throw new Exception (dgettext("domframework",
|
||||
throw new Exception (dgettext ("domframework",
|
||||
"No fieldPassword defined"), 500);
|
||||
if ($this->fieldLastname === null)
|
||||
throw new Exception (dgettext("domframework",
|
||||
throw new Exception (dgettext ("domframework",
|
||||
"No fieldLastname defined"), 500);
|
||||
if ($this->fieldFirstname === null)
|
||||
throw new Exception (dgettext("domframework",
|
||||
throw new Exception (dgettext ("domframework",
|
||||
"No fieldFirstname defined"), 500);
|
||||
$fields = array_merge (array ($this->fieldIdentifier, $this->fieldPassword,
|
||||
$this->fieldLastname, $this->fieldFirstname),
|
||||
@@ -80,7 +80,7 @@ class authsql extends auth
|
||||
public function authentication ($email, $password)
|
||||
{
|
||||
if ($this->db === null)
|
||||
throw new Exception (dgettext("domframework",
|
||||
throw new Exception (dgettext ("domframework",
|
||||
"The SQL database is not connected"), 500);
|
||||
$data = $this->db->read (array (array ($this->fieldIdentifier, $email)),
|
||||
array_merge (array ($this->fieldIdentifier,
|
||||
@@ -89,16 +89,16 @@ class authsql extends auth
|
||||
$this->fieldPassword),
|
||||
$this->fieldsInfo));
|
||||
if (count ($data) === 0)
|
||||
throw new Exception (sprintf (dgettext("domframework",
|
||||
throw new Exception (sprintf (dgettext ("domframework",
|
||||
"Unable to find the user : '%s'"),
|
||||
$email), 401);
|
||||
if (! isset ($data[0][$this->fieldPassword]))
|
||||
throw new Exception (dgettext("domframework",
|
||||
throw new Exception (dgettext ("domframework",
|
||||
"Unable to get the user password from database"),
|
||||
500);
|
||||
$cryptedPassword = $data[0][$this->fieldPassword];
|
||||
if (crypt ($password, $cryptedPassword) !== $cryptedPassword)
|
||||
throw new Exception (sprintf (dgettext("domframework",
|
||||
throw new Exception (sprintf (dgettext ("domframework",
|
||||
"Bad password for '%s'"), $email),
|
||||
401);
|
||||
// The password should never be stored by this function
|
||||
@@ -123,11 +123,11 @@ class authsql extends auth
|
||||
public function changepassword ($oldpassword, $newpassword)
|
||||
{
|
||||
if ($this->db === null)
|
||||
throw new Exception (dgettext("domframework",
|
||||
throw new Exception (dgettext ("domframework",
|
||||
"The SQL database is not connected"), 500);
|
||||
if ($this->details === null ||
|
||||
! isset ($this->details[$this->fieldIdentifier]))
|
||||
throw new Exception (dgettext("domframework",
|
||||
throw new Exception (dgettext ("domframework",
|
||||
"Can't change the password if the user is not authenticated"),
|
||||
500);
|
||||
$data = $this->db->read (array (array ($this->fieldIdentifier,
|
||||
@@ -136,7 +136,7 @@ class authsql extends auth
|
||||
$this->fieldPassword));
|
||||
$cryptedPassword = $data[0][$this->fieldPassword];
|
||||
if (crypt ($oldpassword, $cryptedPassword) !== $cryptedPassword)
|
||||
throw new Exception (dgettext("domframework",
|
||||
throw new Exception (dgettext ("domframework",
|
||||
"Bad old password provided"), 401);
|
||||
$cost = 11;
|
||||
$salt=substr(base64_encode(openssl_random_pseudo_bytes(17)),0,22);
|
||||
@@ -151,7 +151,7 @@ class authsql extends auth
|
||||
$rc = $this->db->update ($this->details[$this->fieldIdentifier],
|
||||
array ($this->fieldPassword => $cryptpassword));
|
||||
if ($rc !== 1)
|
||||
throw new Exception (dgettext("domframework",
|
||||
throw new Exception (dgettext ("domframework",
|
||||
"Can't change the password"), 500);
|
||||
}
|
||||
|
||||
@@ -163,13 +163,13 @@ class authsql extends auth
|
||||
public function overwritepassword ($email, $newpassword)
|
||||
{
|
||||
if ($this->db === null)
|
||||
throw new Exception (dgettext("domframework",
|
||||
throw new Exception (dgettext ("domframework",
|
||||
"The SQL database is not connected"), 500);
|
||||
$data = $this->db->read (array (array ($this->fieldIdentifier, $email)),
|
||||
array ($this->fieldIdentifier,
|
||||
$this->fieldPassword));
|
||||
if (count ($data) === 0)
|
||||
throw new Exception (sprintf (dgettext("domframework",
|
||||
throw new Exception (sprintf (dgettext ("domframework",
|
||||
"Unable to find the user : '%s'"),
|
||||
$email), 401);
|
||||
$cost = 11;
|
||||
@@ -185,15 +185,15 @@ class authsql extends auth
|
||||
$rc = $this->db->update ($email,
|
||||
array ($this->fieldPassword => $cryptpassword));
|
||||
if ($rc !== 1)
|
||||
throw new Exception (dgettext("domframework","Can't change the password"),
|
||||
500);
|
||||
throw new Exception (dgettext ("domframework",
|
||||
"Can't change the password"), 500);
|
||||
}
|
||||
/** List all the users available in the database
|
||||
Return firstname, lastname, mail, with mail is an array */
|
||||
public function listusers ()
|
||||
{
|
||||
if ($this->db === null)
|
||||
throw new Exception (dgettext("domframework",
|
||||
throw new Exception (dgettext ("domframework",
|
||||
"The SQL database is not connected"), 500);
|
||||
$data = $this->db->read (null, array_merge (array ($this->fieldIdentifier,
|
||||
$this->fieldFirstname,
|
||||
|
||||
Reference in New Issue
Block a user