Skip to content

Commit

Permalink
🐛 fixed redirect bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Feb 17, 2022
1 parent 5e42aac commit e7f261d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class Auth extends Core
*
* @return array|null null or all user info + tokens + session data
*/
public static function login(array $credentials) {
public static function login(array $credentials)
{
static::leafDbConnect();

$table = static::$settings['DB_TABLE'];
Expand Down Expand Up @@ -120,7 +121,8 @@ public static function login(array $credentials) {
*
* @return array null or all user info + tokens + session data
*/
public static function register(array $credentials, array $uniques = []) {
public static function register(array $credentials, array $uniques = [])
{
static::leafDbConnect();

$table = static::$settings['DB_TABLE'];
Expand Down Expand Up @@ -353,7 +355,7 @@ public static function update(array $credentials, array $uniques = [])

/**
* Validation for parameters
*
*
* @param array $rules Rules for parameter validation
*/
public function validate(array $rules): bool
Expand Down Expand Up @@ -467,7 +469,7 @@ public static function user(array $hidden = [])

/**
* End a session
*
*
* @param string $location A route to redirect to after logout
*/
public static function logout(?string $location = null)
Expand All @@ -478,7 +480,8 @@ public static function logout(?string $location = null)

if (is_string($location)) {
$route = static::config($location) ?? $location;
exit(\Leaf\Http\Response::redirect($route));
\Leaf\Http\Headers::status(302);
exit(header("location: $route"));
}
}

Expand All @@ -494,7 +497,7 @@ public static function lastActive()

/**
* Refresh session
*
*
* @param bool $clearData Remove existing session data
*/
public static function refresh(bool $clearData = true)
Expand All @@ -512,7 +515,7 @@ public static function refresh(bool $clearData = true)

/**
* Define/Return session middleware
*
*
* @param string $name The name of the middleware to set/get
* @param callable|null $handler The handler for the middleware
*/
Expand Down

0 comments on commit e7f261d

Please sign in to comment.