mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-07 16:46:29 +02:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
7c842f903e | ||
|
0e2279ecda | ||
|
79db94f500 | ||
|
f38d7bd62c | ||
|
04a2e8ef4e | ||
|
59505479a5 | ||
|
fdcfd6f78c | ||
|
20606bc507 | ||
|
89a7af17fe |
32
README.md
32
README.md
@@ -17,8 +17,10 @@ Completely framework-agnostic and database-agnostic.
|
||||
## Requirements
|
||||
|
||||
* PHP 5.6.0+
|
||||
* PDO (PHP Data Objects) extension (`pdo`)
|
||||
* MySQL Native Driver (`mysqlnd`)
|
||||
* OpenSSL extension (`openssl`)
|
||||
* MySQL 5.5.3+ **or** MariaDB 5.5.23+
|
||||
* MySQL 5.5.3+ **or** MariaDB 5.5.23+ **or** other SQL databases that you create the [schema](Database) for
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -323,6 +325,34 @@ Remember that usernames are optional and there is only a username if you supplie
|
||||
|
||||
If the user is not currently signed in, this returns `null`.
|
||||
|
||||
#### Status information
|
||||
|
||||
```php
|
||||
if ($auth->isNormal()) {
|
||||
// user is in default state
|
||||
}
|
||||
|
||||
if ($auth->isArchived()) {
|
||||
// user has been archived
|
||||
}
|
||||
|
||||
if ($auth->isBanned()) {
|
||||
// user has been banned
|
||||
}
|
||||
|
||||
if ($auth->isLocked()) {
|
||||
// user has been locked
|
||||
}
|
||||
|
||||
if ($auth->isPendingReview()) {
|
||||
// user is pending review
|
||||
}
|
||||
|
||||
if ($auth->isSuspended()) {
|
||||
// user has been suspended
|
||||
}
|
||||
```
|
||||
|
||||
#### Checking whether the user was "remembered"
|
||||
|
||||
```php
|
||||
|
@@ -5,7 +5,7 @@
|
||||
"php": ">=5.6.0",
|
||||
"ext-openssl": "*",
|
||||
"delight-im/cookie": "^2.1",
|
||||
"delight-im/db": "^1.0"
|
||||
"delight-im/db": "^1.2"
|
||||
},
|
||||
"type": "library",
|
||||
"keywords": [ "auth", "authentication", "login", "security" ],
|
||||
|
27
composer.lock
generated
27
composer.lock
generated
@@ -4,26 +4,25 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "bd80e3e52b8bd8a4a0c74c7cf9f5bf5e",
|
||||
"content-hash": "3f836c43e0ff2293051f2ccb739d23cf",
|
||||
"content-hash": "c075bec19490fc0e972be01cdd02d59b",
|
||||
"packages": [
|
||||
{
|
||||
"name": "delight-im/cookie",
|
||||
"version": "v2.1.0",
|
||||
"version": "v2.1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/delight-im/PHP-Cookie.git",
|
||||
"reference": "3e41e0d44959b59de98722b5b1b1fb83f9f528f3"
|
||||
"reference": "22f2c19750a6ad3dbf69a8ef3ea0e454a8e064fa"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/delight-im/PHP-Cookie/zipball/3e41e0d44959b59de98722b5b1b1fb83f9f528f3",
|
||||
"reference": "3e41e0d44959b59de98722b5b1b1fb83f9f528f3",
|
||||
"url": "https://api.github.com/repos/delight-im/PHP-Cookie/zipball/22f2c19750a6ad3dbf69a8ef3ea0e454a8e064fa",
|
||||
"reference": "22f2c19750a6ad3dbf69a8ef3ea0e454a8e064fa",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"delight-im/http": "^2.0",
|
||||
"php": ">=5.3.0"
|
||||
"php": ">=5.6.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
@@ -46,20 +45,20 @@
|
||||
"samesite",
|
||||
"xss"
|
||||
],
|
||||
"time": "2016-11-23 20:09:42"
|
||||
"time": "2016-12-18T20:22:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "delight-im/db",
|
||||
"version": "v1.0.2",
|
||||
"version": "v1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/delight-im/PHP-DB.git",
|
||||
"reference": "c8d1eba6583007471d55bf7d88eb3c9d87ea849d"
|
||||
"reference": "df99ef7c2e86c7ce206647ffe8ba74447c075b57"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/delight-im/PHP-DB/zipball/c8d1eba6583007471d55bf7d88eb3c9d87ea849d",
|
||||
"reference": "c8d1eba6583007471d55bf7d88eb3c9d87ea849d",
|
||||
"url": "https://api.github.com/repos/delight-im/PHP-DB/zipball/df99ef7c2e86c7ce206647ffe8ba74447c075b57",
|
||||
"reference": "df99ef7c2e86c7ce206647ffe8ba74447c075b57",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -87,7 +86,7 @@
|
||||
"sql",
|
||||
"sqlite"
|
||||
],
|
||||
"time": "2016-12-01 12:40:36"
|
||||
"time": "2017-03-18T20:51:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "delight-im/http",
|
||||
@@ -123,7 +122,7 @@
|
||||
"http",
|
||||
"https"
|
||||
],
|
||||
"time": "2016-07-21 15:05:01"
|
||||
"time": "2016-07-21T15:05:01+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
|
@@ -38,6 +38,10 @@ class AuthError extends \Exception {}
|
||||
|
||||
class DatabaseError extends AuthError {}
|
||||
|
||||
class DatabaseDriverError extends DatabaseError {}
|
||||
|
||||
class WrongMysqlDatabaseDriverError extends DatabaseDriverError {}
|
||||
|
||||
class MissingCallbackError extends AuthError {}
|
||||
|
||||
class HeadersAlreadySentError extends AuthError {}
|
||||
|
@@ -66,6 +66,16 @@ abstract class UserManager {
|
||||
|
||||
throw new \InvalidArgumentException('The database connection must be an instance of either `PdoDatabase`, `PdoDsn` or `PDO`');
|
||||
}
|
||||
|
||||
$this->db->addOnConnectListener(function (PdoDatabase $db) {
|
||||
// if a MySQL database is used
|
||||
if ($db->getDriverName() === 'MySQL') {
|
||||
// if the required MySQL Native Driver (mysqlnd) is not used (but instead the older MySQL Client Library (libmysqlclient))
|
||||
if (\extension_loaded('mysqlnd') === false && \stripos($db->getClientVersion(), 'mysqlnd') === false) {
|
||||
throw new WrongMysqlDatabaseDriverError('You must use PDO with the newer \'mysqlnd\' driver instead of the older \'libmysqlclient\' driver');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user