1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-08-05 15:47:25 +02:00

Rename two methods for logout to highlight the better default version

This commit is contained in:
Marco
2017-10-19 20:25:11 +02:00
parent ce8dbbc436
commit 71506eaa05
4 changed files with 15 additions and 13 deletions

View File

@@ -18,6 +18,8 @@ $ composer update delight-im/auth
## From `v6.x.x` to `v7.x.x` ## From `v6.x.x` to `v7.x.x`
* The method `logOutButKeepSession` from class `Auth` is now simply called `logOut`. Therefore, the former method `logout` is now called `logOutAndDestroySession`. With both methods, mind the capitalization of the letter “O”.
## From `v5.x.x` to `v6.x.x` ## From `v5.x.x` to `v6.x.x`
* The database schema has changed. * The database schema has changed.

View File

@@ -407,9 +407,9 @@ $url = 'https://www.example.com/verify_email?selector=' . \urlencode($selector)
### Logout ### Logout
```php ```php
$auth->logOutButKeepSession(); $auth->logOut();
// or // or
$auth->logout(); $auth->logOutAndDestroySession();
// user has been signed out // user has been signed out
``` ```

View File

@@ -339,7 +339,7 @@ final class Auth extends UserManager {
* *
* @throws AuthError if an internal problem occurred (do *not* catch) * @throws AuthError if an internal problem occurred (do *not* catch)
*/ */
public function logOutButKeepSession() { public function logOut() {
// if the user has been signed in // if the user has been signed in
if ($this->isLoggedIn()) { if ($this->isLoggedIn()) {
// get the user's ID // get the user's ID
@@ -534,8 +534,8 @@ final class Auth extends UserManager {
* *
* @throws AuthError if an internal problem occurred (do *not* catch) * @throws AuthError if an internal problem occurred (do *not* catch)
*/ */
public function logout() { public function logOutAndDestroySession() {
$this->logOutButKeepSession(); $this->logOut();
$this->destroySession(); $this->destroySession();
} }

View File

@@ -357,13 +357,13 @@ function processRequestData(\Delight\Auth\Auth $auth) {
return 'not logged in'; return 'not logged in';
} }
} }
else if ($_POST['action'] === 'logOutButKeepSession') { else if ($_POST['action'] === 'logOut') {
$auth->logOutButKeepSession(); $auth->logOut();
return 'ok'; return 'ok';
} }
else if ($_POST['action'] === 'logout') { else if ($_POST['action'] === 'logOutAndDestroySession') {
$auth->logout(); $auth->logOutAndDestroySession();
return 'ok'; return 'ok';
} }
@@ -672,13 +672,13 @@ function showAuthenticatedUserForm(\Delight\Auth\Auth $auth) {
echo '</form>'; echo '</form>';
echo '<form action="" method="post" accept-charset="utf-8">'; echo '<form action="" method="post" accept-charset="utf-8">';
echo '<input type="hidden" name="action" value="logOutButKeepSession" />'; echo '<input type="hidden" name="action" value="logOut" />';
echo '<button type="submit">Log out but keep session</button>'; echo '<button type="submit">Log out</button>';
echo '</form>'; echo '</form>';
echo '<form action="" method="post" accept-charset="utf-8">'; echo '<form action="" method="post" accept-charset="utf-8">';
echo '<input type="hidden" name="action" value="logout" />'; echo '<input type="hidden" name="action" value="logOutAndDestroySession" />';
echo '<button type="submit">Log out</button>'; echo '<button type="submit">Log out and destroy session</button>';
echo '</form>'; echo '</form>';
} }