mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-04 08:54:33 +08:00
Added testing coverage to API token auth
This commit is contained in:
@ -150,4 +150,11 @@ class ApiTokenGuard implements Guard
|
||||
return Hash::check($credentials['secret'], $token->secret);
|
||||
}
|
||||
|
||||
/**
|
||||
* "Log out" the currently authenticated user.
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
$this->user = null;
|
||||
}
|
||||
}
|
@ -72,7 +72,7 @@ class Role extends Model
|
||||
*/
|
||||
public function detachPermission(RolePermission $permission)
|
||||
{
|
||||
$this->permissions()->detach($permission->id);
|
||||
$this->permissions()->detach([$permission->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@ class ApiAuthenticate
|
||||
}
|
||||
|
||||
if ($this->awaitingEmailConfirmation()) {
|
||||
return $this->emailConfirmationErrorResponse($request);
|
||||
return $this->emailConfirmationErrorResponse($request, true);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
@ -26,9 +26,9 @@ trait ChecksForEmailConfirmation
|
||||
* Provide an error response for when the current user's email is not confirmed
|
||||
* in a system which requires it.
|
||||
*/
|
||||
protected function emailConfirmationErrorResponse(Request $request)
|
||||
protected function emailConfirmationErrorResponse(Request $request, bool $forceJson = false)
|
||||
{
|
||||
if ($request->wantsJson()) {
|
||||
if ($request->wantsJson() || $forceJson) {
|
||||
return response()->json([
|
||||
'error' => [
|
||||
'code' => 401,
|
||||
|
Reference in New Issue
Block a user