1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-08-08 17:16:29 +02:00

2 Commits

Author SHA1 Message Date
Marco
f6607f664d Enhance 'DatabaseError' instances to be more verbose 2018-04-20 18:01:00 +02:00
Marco
49a4ef8280 Document required database privileges in README 2018-04-03 14:48:10 +02:00
4 changed files with 32 additions and 32 deletions

View File

@@ -114,7 +114,7 @@ Migrating from an earlier version of this project? See our [upgrade guide](Migra
$auth = new \Delight\Auth\Auth($db);
```
If you have an open `PDO` connection already, just re-use it.
If you have an open `PDO` connection already, just re-use it. The database user (e.g. `my-username`) needs at least the privileges `SELECT`, `INSERT`, `UPDATE` and `DELETE` for the tables used by this library (or their parent database).
If your web server is behind a proxy server and `$_SERVER['REMOTE_ADDR']` only contains the proxys IP address, you must pass the users real IP address to the constructor in the second argument, which is named `$ipAddress`. The default is the usual remote IP address received by PHP.

View File

@@ -432,7 +432,7 @@ final class Administration extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
}
@@ -457,7 +457,7 @@ final class Administration extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
if ($userData === null) {
@@ -478,7 +478,7 @@ final class Administration extends UserManager {
return true;
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
}
@@ -549,7 +549,7 @@ final class Administration extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
$numberOfMatchingUsers = ($users !== null) ? \count($users) : 0;

View File

@@ -119,7 +119,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
if (!empty($rememberData)) {
@@ -161,7 +161,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
// if the user's data has been found
@@ -358,7 +358,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
if (!empty($expectedHash)) {
@@ -506,7 +506,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
$this->setRememberCookie($selector, $token, $expires);
@@ -572,7 +572,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
parent::onLoginSuccessful($userId, $email, $username, $status, $roles, $forceLogout, $remembered);
@@ -625,7 +625,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
if (!empty($confirmationData)) {
@@ -639,7 +639,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
// mark the email address as verified (and possibly update it to the new address given)
@@ -657,7 +657,7 @@ final class Auth extends UserManager {
throw new UserAlreadyExistsException();
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
// if the user is currently signed in
@@ -677,7 +677,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
// if the email address has not been changed but simply been verified
@@ -822,7 +822,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
if ((int) $existingUsersWithNewEmail !== 0) {
@@ -836,7 +836,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
// ensure that at least the current (old) email address has been verified before proceeding
@@ -924,7 +924,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
if ($latestAttempt === null) {
@@ -1137,7 +1137,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
if (!empty($userData)) {
@@ -1173,7 +1173,7 @@ final class Auth extends UserManager {
}
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
}
@@ -1211,7 +1211,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
if (\is_callable($callback)) {
@@ -1249,7 +1249,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
if (!empty($resetData)) {
@@ -1267,7 +1267,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
}
else {
@@ -1365,7 +1365,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
}
else {
@@ -1391,7 +1391,7 @@ final class Auth extends UserManager {
return (int) $enabled === 1;
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
}
else {
@@ -1692,7 +1692,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
if ($bucket === null) {
@@ -1730,7 +1730,7 @@ final class Auth extends UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
if ($affected === 0) {
@@ -1744,7 +1744,7 @@ final class Auth extends UserManager {
}
catch (IntegrityConstraintViolationException $ignored) {}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
}
}

View File

@@ -172,7 +172,7 @@ abstract class UserManager {
throw new UserAlreadyExistsException();
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
$newUserId = (int) $this->db->getLastInsertId();
@@ -207,7 +207,7 @@ abstract class UserManager {
}
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
}
@@ -263,7 +263,7 @@ abstract class UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
if (empty($users)) {
@@ -356,7 +356,7 @@ abstract class UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
if (\is_callable($callback)) {
@@ -390,7 +390,7 @@ abstract class UserManager {
);
}
catch (Error $e) {
throw new DatabaseError();
throw new DatabaseError($e->getMessage());
}
}