mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 21:49:01 +01:00
Auto authenticate the user if logged in
This commit is contained in:
parent
2baf17b9d5
commit
f550a7369e
@ -45,20 +45,22 @@ class ApiAuthenticate
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($apiToken = $request->header('X-Cachet-Token')) {
|
||||
try {
|
||||
$user = User::findByApiToken($apiToken);
|
||||
if ($this->auth->guest()) {
|
||||
if ($apiToken = $request->header('X-Cachet-Token')) {
|
||||
try {
|
||||
$user = User::findByApiToken($apiToken);
|
||||
|
||||
$this->auth->onceUsingId($user->id);
|
||||
} catch (ModelNotFoundException $e) {
|
||||
$this->auth->onceUsingId($user->id);
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return $this->handleError();
|
||||
}
|
||||
} elseif ($user = $request->getUser()) {
|
||||
if ($this->auth->onceBasic() !== null) {
|
||||
return $this->handleError();
|
||||
}
|
||||
} else {
|
||||
return $this->handleError();
|
||||
}
|
||||
} elseif ($user = $request->getUser()) {
|
||||
if ($this->auth->onceBasic() !== null) {
|
||||
return $this->handleError();
|
||||
}
|
||||
} else {
|
||||
return $this->handleError();
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
Loading…
x
Reference in New Issue
Block a user