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',[
|
\Log::warning('Impersonation started',[
|
||||||
'from_id' => auth()->id(),
|
'from_id' => auth()->id(),
|
||||||
'from_email' => auth()->user()->email,
|
'from_email' => auth()->user()->email,
|
||||||
|
@ -47,15 +46,11 @@ class ImpersonationController extends Controller
|
||||||
'target_email' => $user->id,
|
'target_email' => $user->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Be this user
|
$token = auth()->claims(auth()->user()->admin ? [] : [
|
||||||
if (auth()->user()->moderator) {
|
'impersonating' => true,
|
||||||
$token = auth()->claims([
|
'impersonator_id' => auth()->id(),
|
||||||
'impersonating' => true,
|
])->login($user);
|
||||||
'impersonator_id' => auth()->id(),
|
|
||||||
])->login($user);
|
|
||||||
} else {
|
|
||||||
$token = auth()->login($user);
|
|
||||||
}
|
|
||||||
return $this->success([
|
return $this->success([
|
||||||
'token' => $token
|
'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}',
|
Route::get('impersonate/{identifier}',
|
||||||
[\App\Http\Controllers\Admin\ImpersonationController::class, 'impersonate']);
|
[\App\Http\Controllers\Admin\ImpersonationController::class, 'impersonate']);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue