1
ユーザーのために再アクティブ化オプションを作成したいという問題がありますが、何度か試してもうまくいかず、混乱します。Laravelで 'Reactivation'オプションを作成する
public function handle($request, Closure $next)
{
if (!Auth::check()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('/');
}
}
else
{
$user = Auth::user();
if (!$user->activated) {
$activation = action('Auth\[email protected]', ['username' => $user->username]);
Auth::logout();
return redirect()->guest('auth')
->withErrors(array('message' => 'Please activate your account. Re-send your activation by clicking <a href=' . $activation . '>here</a>.'));
}
else if (!$user->enabled) {
Auth::logout();
return redirect('/auth')->withErrors(array('message' => 'Your account has been deactivated. Please email ... for any inquiries.'))->withInput();
// I tried to add the same method as the above if statement but not working here
}
$user->runDailyNotifications();
}
return $next($request);
}
私はこの方法を使用して、私のデータベースを更新したかった:正常に動作しなければならない
$user = Auth::user();
$user->enabled = 1;
$user->save();
ここ
は、ミドルウェア(オリジナルバージョン)です。私はLaravelを初めて利用しています。最初は、これらのコードをミドルウェアに追加しました(これは間違いです)。
ちょっと試した後、ユーザーがログインを2回クリックするとアカウントを無効にした後にログインすることはできません。今どこからでもエラーメッセージを受け取ってから、どのように達成できるのだろうかと思っています。お手伝いありがとう!