mirror of
https://github.com/flarum/framework.git
synced 2024-12-12 06:03:39 +08:00
Disable session (and thus enable sudo mode) when authenticating with API token
This commit is contained in:
parent
2777162d32
commit
d242894938
|
@ -37,10 +37,10 @@ class AuthenticateWithHeader implements MiddlewareInterface
|
|||
if (isset($parts[0]) && starts_with($parts[0], $this->prefix)) {
|
||||
$id = substr($parts[0], strlen($this->prefix));
|
||||
|
||||
if (isset($parts[1]) && ApiKey::find($id)) {
|
||||
if (isset($parts[1])) {
|
||||
if (ApiKey::find($id)) {
|
||||
$actor = $this->getUser($parts[1]);
|
||||
|
||||
$request->getAttribute('session')->set('sudo_expiry', new DateTime);
|
||||
}
|
||||
} elseif ($token = AccessToken::find($id)) {
|
||||
$token->touch();
|
||||
|
||||
|
@ -49,6 +49,7 @@ class AuthenticateWithHeader implements MiddlewareInterface
|
|||
|
||||
if (isset($actor)) {
|
||||
$request = $request->withAttribute('actor', $actor);
|
||||
$request = $request->withoutAttribute('session');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user