1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-07-31 13:20:11 +02:00

Fix referenced namespaces to be absolute or fully qualified

This commit is contained in:
Marco
2015-10-30 09:34:32 +01:00
parent 5a954ca13b
commit 90fe75c27e
2 changed files with 34 additions and 34 deletions

View File

@@ -46,7 +46,7 @@ Completely framework-agnostic and database-agnostic.
// $db = new PDO('mysql:dbname=database;host=localhost;charset=utf8', 'username', 'password'); // $db = new PDO('mysql:dbname=database;host=localhost;charset=utf8', 'username', 'password');
// $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$auth = new Delight\Auth\Auth($db); $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.
@@ -67,16 +67,16 @@ try {
// we have signed up a new user with the ID `$userId` // we have signed up a new user with the ID `$userId`
} }
catch (Delight\Auth\InvalidEmailException $e) { catch (\Delight\Auth\InvalidEmailException $e) {
// invalid email address // invalid email address
} }
catch (Delight\Auth\InvalidPasswordException $e) { catch (\Delight\Auth\InvalidPasswordException $e) {
// invalid password // invalid password
} }
catch (Delight\Auth\UserAlreadyExistsException $e) { catch (\Delight\Auth\UserAlreadyExistsException $e) {
// user already exists // user already exists
} }
catch (Delight\Auth\TooManyRequestsException $e) { catch (\Delight\Auth\TooManyRequestsException $e) {
// too many requests // too many requests
} }
``` ```
@@ -99,16 +99,16 @@ try {
// user is logged in // user is logged in
} }
catch (Delight\Auth\InvalidEmailException $e) { catch (\Delight\Auth\InvalidEmailException $e) {
// wrong email address // wrong email address
} }
catch (Delight\Auth\InvalidPasswordException $e) { catch (\Delight\Auth\InvalidPasswordException $e) {
// wrong password // wrong password
} }
catch (Delight\Auth\EmailNotVerifiedException $e) { catch (\Delight\Auth\EmailNotVerifiedException $e) {
// email not verified // email not verified
} }
catch (Delight\Auth\TooManyRequestsException $e) { catch (\Delight\Auth\TooManyRequestsException $e) {
// too many requests // too many requests
} }
``` ```
@@ -125,13 +125,13 @@ try {
// email address has been verified // email address has been verified
} }
catch (Delight\Auth\InvalidSelectorTokenPairException $e) { catch (\Delight\Auth\InvalidSelectorTokenPairException $e) {
// invalid token // invalid token
} }
catch (Delight\Auth\TokenExpiredException $e) { catch (\Delight\Auth\TokenExpiredException $e) {
// token expired // token expired
} }
catch (Delight\Auth\TooManyRequestsException $e) { catch (\Delight\Auth\TooManyRequestsException $e) {
// too many requests // too many requests
} }
``` ```
@@ -146,10 +146,10 @@ try {
// password has been changed // password has been changed
} }
catch (Delight\Auth\NotLoggedInException $e) { catch (\Delight\Auth\NotLoggedInException $e) {
// not logged in // not logged in
} }
catch (Delight\Auth\InvalidPasswordException $e) { catch (\Delight\Auth\InvalidPasswordException $e) {
// invalid password(s) // invalid password(s)
} }
``` ```
@@ -228,13 +228,13 @@ $ip = $auth->getIpAddress();
```php ```php
$length = 24; $length = 24;
$randomStr = Delight\Auth\Auth::createRandomString($length); $randomStr = \Delight\Auth\Auth::createRandomString($length);
``` ```
#### Create a UUID v4 as per RFC 4122 #### Create a UUID v4 as per RFC 4122
```php ```php
$uuid = Delight\Auth\Auth::createUuid(); $uuid = \Delight\Auth\Auth::createUuid();
``` ```
## Features ## Features

View File

@@ -25,7 +25,7 @@ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
require __DIR__.'/../src/Auth.php'; require __DIR__.'/../src/Auth.php';
$auth = new Delight\Auth\Auth($db); $auth = new \Delight\Auth\Auth($db);
$result = processRequestData($auth); $result = processRequestData($auth);
@@ -38,7 +38,7 @@ else {
showGuestUserForm(); showGuestUserForm();
} }
function processRequestData(Delight\Auth\Auth $auth) { function processRequestData(\Delight\Auth\Auth $auth) {
if (isset($_POST)) { if (isset($_POST)) {
if (isset($_POST['action'])) { if (isset($_POST['action'])) {
if ($_POST['action'] === 'login') { if ($_POST['action'] === 'login') {
@@ -47,16 +47,16 @@ function processRequestData(Delight\Auth\Auth $auth) {
return 'ok'; return 'ok';
} }
catch (Delight\Auth\InvalidEmailException $e) { catch (\Delight\Auth\InvalidEmailException $e) {
return 'wrong email address'; return 'wrong email address';
} }
catch (Delight\Auth\InvalidPasswordException $e) { catch (\Delight\Auth\InvalidPasswordException $e) {
return 'wrong password'; return 'wrong password';
} }
catch (Delight\Auth\EmailNotVerifiedException $e) { catch (\Delight\Auth\EmailNotVerifiedException $e) {
return 'email not verified'; return 'email not verified';
} }
catch (Delight\Auth\TooManyRequestsException $e) { catch (\Delight\Auth\TooManyRequestsException $e) {
return 'too many requests'; return 'too many requests';
} }
} }
@@ -83,16 +83,16 @@ function processRequestData(Delight\Auth\Auth $auth) {
return $auth->register($_POST['email'], $_POST['password'], $_POST['username'], $callback); return $auth->register($_POST['email'], $_POST['password'], $_POST['username'], $callback);
} }
catch (Delight\Auth\InvalidEmailException $e) { catch (\Delight\Auth\InvalidEmailException $e) {
return 'invalid email address'; return 'invalid email address';
} }
catch (Delight\Auth\InvalidPasswordException $e) { catch (\Delight\Auth\InvalidPasswordException $e) {
return 'invalid password'; return 'invalid password';
} }
catch (Delight\Auth\UserAlreadyExistsException $e) { catch (\Delight\Auth\UserAlreadyExistsException $e) {
return 'user already exists'; return 'user already exists';
} }
catch (Delight\Auth\TooManyRequestsException $e) { catch (\Delight\Auth\TooManyRequestsException $e) {
return 'too many requests'; return 'too many requests';
} }
} }
@@ -102,13 +102,13 @@ function processRequestData(Delight\Auth\Auth $auth) {
return 'ok'; return 'ok';
} }
catch (Delight\Auth\InvalidSelectorTokenPairException $e) { catch (\Delight\Auth\InvalidSelectorTokenPairException $e) {
return 'invalid token'; return 'invalid token';
} }
catch (Delight\Auth\TokenExpiredException $e) { catch (\Delight\Auth\TokenExpiredException $e) {
return 'token expired'; return 'token expired';
} }
catch (Delight\Auth\TooManyRequestsException $e) { catch (\Delight\Auth\TooManyRequestsException $e) {
return 'too many requests'; return 'too many requests';
} }
} }
@@ -118,10 +118,10 @@ function processRequestData(Delight\Auth\Auth $auth) {
return 'ok'; return 'ok';
} }
catch (Delight\Auth\NotLoggedInException $e) { catch (\Delight\Auth\NotLoggedInException $e) {
return 'not logged in'; return 'not logged in';
} }
catch (Delight\Auth\InvalidPasswordException $e) { catch (\Delight\Auth\InvalidPasswordException $e) {
return 'invalid password(s)'; return 'invalid password(s)';
} }
} }
@@ -139,7 +139,7 @@ function processRequestData(Delight\Auth\Auth $auth) {
return null; return null;
} }
function showDebugData(Delight\Auth\Auth $auth, $result) { function showDebugData(\Delight\Auth\Auth $auth, $result) {
echo '<pre>'; echo '<pre>';
echo 'Last operation'."\t\t\t\t"; echo 'Last operation'."\t\t\t\t";
@@ -171,9 +171,9 @@ function showDebugData(Delight\Auth\Auth $auth, $result) {
echo "\n"; echo "\n";
echo 'Auth::createRandomString()'."\t\t"; echo 'Auth::createRandomString()'."\t\t";
var_dump(Delight\Auth\Auth::createRandomString()); var_dump(\Delight\Auth\Auth::createRandomString());
echo 'Auth::createUuid()'."\t\t\t"; echo 'Auth::createUuid()'."\t\t\t";
var_dump(Delight\Auth\Auth::createUuid()); var_dump(\Delight\Auth\Auth::createUuid());
echo '</pre>'; echo '</pre>';
} }