Fix impersonation for moderator
This commit is contained in:
parent
2babb5c637
commit
3a25178697
|
@ -39,7 +39,6 @@ class ImpersonationController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
|
||||
\Log::warning('Impersonation started',[
|
||||
'from_id' => auth()->id(),
|
||||
'from_email' => auth()->user()->email,
|
||||
|
@ -47,15 +46,11 @@ class ImpersonationController extends Controller
|
|||
'target_email' => $user->id,
|
||||
]);
|
||||
|
||||
// Be this user
|
||||
if (auth()->user()->moderator) {
|
||||
$token = auth()->claims([
|
||||
$token = auth()->claims(auth()->user()->admin ? [] : [
|
||||
'impersonating' => true,
|
||||
'impersonator_id' => auth()->id(),
|
||||
])->login($user);
|
||||
} else {
|
||||
$token = auth()->login($user);
|
||||
}
|
||||
|
||||
return $this->success([
|
||||
'token' => $token
|
||||
]);
|
||||
|
|
|
@ -116,7 +116,7 @@ Route::group(['middleware' => 'auth:api'], function () {
|
|||
});
|
||||
});
|
||||
|
||||
Route::group(['middleware' => 'admin', 'prefix' => 'admin'], function () {
|
||||
Route::group(['middleware' => 'moderator', 'prefix' => 'admin'], function () {
|
||||
Route::get('impersonate/{identifier}',
|
||||
[\App\Http\Controllers\Admin\ImpersonationController::class, 'impersonate']);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue