我有一個 Laravel Web 應用程式,其中多個用戶登錄,但如果用戶已經登錄,我需要阻止登錄。
我知道 Laravel 有一種方法(logoutOtherDevices)可以在第二個用戶(相同的憑據)登錄時注銷用戶。
\Illuminate\Session\Middleware\AuthenticateSession::class,在 app/Http/Kernel.php 中取消注釋 。
但是我懷疑下面提到的代碼在哪里包含?
使用 Illuminate\Support\Facades\Auth;
Auth::logoutOtherDevices($currentPassword);
回答
public function authenticated(Request $request)
{
Auth::logoutOtherDevices($request->password);
if (Auth::check() && Auth::user()->role_id == 1) {
return redirect('/admin/dashboard');
}
$config = DB::table('config')->get();
/*starts*/
$id = Session::get('selected_plan_id');
if(empty($id))
{
return redirect('/user/dashboard');
}
else
{
$selected_plan = Plan::where('plan_id', $id)->where('status', 1)->first();
if ($selected_plan == null) {
alert()->error('Your current plan is not available. Choose another plan.');
return redirect('/user/plans');
} else {
if ($selected_plan == null) {
return view('errors.404');
} else {
return redirect('/user/rediretoCheckout');
}
}
}
}
你需要包括 Auth::logoutOtherDevices($request->password); 贏取驗證碼
uj5u.com熱心網友回復:
你可以使用 Auth 門面提供的 logoutOtherDevices 方法。此方法要求用戶確認他們當前的密碼,您的應用程式應通過輸入表單接受該密碼:在 Controller-> Login Mehthod 中添加
使用 Illuminate\Support\Facades\Auth;
Auth::logoutOtherDevices($currentPassword);
在這里您將獲得更多詳細資訊
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/497082.html
下一篇:Scala字串到Char
