From c6ac81dcf6386206bee0b97a8a93ee2e0befe8bd Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 29 Mar 2016 13:52:51 +0200 Subject: [PATCH] Some more confirmation things. --- app/Handlers/Events/UserConfirmation.php | 3 ++- app/Http/Middleware/IsConfirmed.php | 5 ++++- app/Http/Middleware/IsNotConfirmed.php | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Handlers/Events/UserConfirmation.php b/app/Handlers/Events/UserConfirmation.php index 355b8d9e42..8b3e8f86c1 100644 --- a/app/Handlers/Events/UserConfirmation.php +++ b/app/Handlers/Events/UserConfirmation.php @@ -67,11 +67,12 @@ class UserConfirmation // if user must confirm account, send email $confirmAccount = env('MUST_CONFIRM_ACCOUNT', false); - + // otherwise, auto-confirm: if ($confirmAccount === false) { Preferences::setForUser($user, 'user_confirmed', true); Preferences::setForUser($user, 'user_confirmed_last_mail', 0); + Preferences::mark(); return; } diff --git a/app/Http/Middleware/IsConfirmed.php b/app/Http/Middleware/IsConfirmed.php index 9181bc6e82..50854de79a 100644 --- a/app/Http/Middleware/IsConfirmed.php +++ b/app/Http/Middleware/IsConfirmed.php @@ -42,9 +42,12 @@ class IsConfirmed return redirect()->guest('login'); } } else { + // must the user be confirmed in the first place? + $confirmAccount = env('MUST_CONFIRM_ACCOUNT', false); // user must be logged in, then continue: $isConfirmed = Preferences::get('user_confirmed', false)->data; - if ($isConfirmed === false) { + + if ($isConfirmed === false && $confirmAccount === true) { // user account is not confirmed, redirect to // confirmation page: diff --git a/app/Http/Middleware/IsNotConfirmed.php b/app/Http/Middleware/IsNotConfirmed.php index ca7f6d482f..7baffc3968 100644 --- a/app/Http/Middleware/IsNotConfirmed.php +++ b/app/Http/Middleware/IsNotConfirmed.php @@ -42,9 +42,11 @@ class IsNotConfirmed return redirect()->guest('login'); } } else { + // must the user be confirmed in the first place? + $confirmAccount = env('MUST_CONFIRM_ACCOUNT', false); // user must be logged in, then continue: $isConfirmed = Preferences::get('user_confirmed', false)->data; - if ($isConfirmed) { + if ($isConfirmed || $confirmAccount === false) { // user account is confirmed, simply send them home. return redirect(route('home')); }