1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-08-05 07:37: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`
* 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`
* The database schema has changed.

View File

@@ -407,9 +407,9 @@ $url = 'https://www.example.com/verify_email?selector=' . \urlencode($selector)
### Logout
```php
$auth->logOutButKeepSession();
$auth->logOut();
// or
$auth->logout();
$auth->logOutAndDestroySession();
// 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)
*/
public function logOutButKeepSession() {
public function logOut() {
// if the user has been signed in
if ($this->isLoggedIn()) {
// get the user's ID
@@ -534,8 +534,8 @@ final class Auth extends UserManager {
*
* @throws AuthError if an internal problem occurred (do *not* catch)
*/
public function logout() {
$this->logOutButKeepSession();
public function logOutAndDestroySession() {
$this->logOut();
$this->destroySession();
}

View File

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