diff --git a/app/Events/ConfirmedUser.php b/app/Events/ConfirmedUser.php deleted file mode 100644 index 20fe797488..0000000000 --- a/app/Events/ConfirmedUser.php +++ /dev/null @@ -1,42 +0,0 @@ -user = $user; - $this->ipAddress = $ipAddress; - } -} diff --git a/app/Events/ResentConfirmation.php b/app/Events/ResentConfirmation.php deleted file mode 100644 index 1ce53d51b3..0000000000 --- a/app/Events/ResentConfirmation.php +++ /dev/null @@ -1,42 +0,0 @@ -user = $user; - $this->ipAddress = $ipAddress; - } -} diff --git a/app/Handlers/Events/UserEventHandler.php b/app/Handlers/Events/UserEventHandler.php index 9c4cd303a9..5144843bf7 100644 --- a/app/Handlers/Events/UserEventHandler.php +++ b/app/Handlers/Events/UserEventHandler.php @@ -15,9 +15,7 @@ namespace FireflyIII\Handlers\Events; use FireflyIII\Events\RegisteredUser; use FireflyIII\Events\RequestedNewPassword; -use FireflyIII\Events\ResentConfirmation; use FireflyIII\Repositories\User\UserRepositoryInterface; -use FireflyIII\Support\Events\SendUserMail; use Illuminate\Mail\Message; use Log; use Mail; @@ -70,37 +68,6 @@ class UserEventHandler return true; } - /** - * This method will send a newly registered user a confirmation message, urging him or her to activate their account. - * - * @param RegisteredUser $event - * - * @return bool - */ - public function sendConfirmationMessage(RegisteredUser $event): bool - { - $sender = new SendUserMail; - - return $sender->sendConfirmation($event->user, $event->ipAddress); - } - - /** - * If the user has somehow lost his or her confirmation message, this event will send it to the user again. - * - * At the moment, this method is exactly the same as the ::sendConfirmationMessage method, but that will change. - * - * @param ResentConfirmation $event - * - * @return bool - */ - function sendConfirmationMessageAgain(ResentConfirmation $event): bool - { - $sender = new SendUserMail; - - return $sender->sendConfirmation($event->user, $event->ipAddress); - - } - /** * @param RequestedNewPassword $event * diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 0770e01ff3..9fcb8b9a99 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -14,7 +14,6 @@ declare(strict_types = 1); namespace FireflyIII\Http\Controllers\Admin; -use FireflyConfig; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Requests\UserFormRequest; use FireflyIII\Repositories\User\UserRepositoryInterface; @@ -81,15 +80,15 @@ class UserController extends Controller */ public function index(UserRepositoryInterface $repository) { - $subTitle = strval(trans('firefly.user_administration')); - $subTitleIcon = 'fa-users'; - $users = $repository->all(); + $subTitle = strval(trans('firefly.user_administration')); + $subTitleIcon = 'fa-users'; + $users = $repository->all(); // add meta stuff. $users->each( function (User $user) { - $list = ['twoFactorAuthEnabled', 'twoFactorAuthSecret']; - $preferences = Preferences::getArrayForUser($user, $list); + $list = ['twoFactorAuthEnabled', 'twoFactorAuthSecret']; + $preferences = Preferences::getArrayForUser($user, $list); $user->isAdmin = $user->hasRole('owner'); $is2faEnabled = $preferences['twoFactorAuthEnabled'] === true; $has2faSecret = !is_null($preferences['twoFactorAuthSecret']); @@ -115,37 +114,12 @@ class UserController extends Controller $mainTitleIcon = 'fa-hand-spock-o'; $subTitle = strval(trans('firefly.single_user_administration', ['email' => $user->email])); $subTitleIcon = 'fa-user'; - - // get IP info: - $defaultIp = '0.0.0.0'; - $regPref = Preferences::getForUser($user, 'registration_ip_address'); - $registration = $defaultIp; - $conPref = Preferences::getForUser($user, 'confirmation_ip_address'); - $confirmation = $defaultIp; - if (!is_null($regPref)) { - $registration = $regPref->data; - } - if (!is_null($conPref)) { - $confirmation = $conPref->data; - } - - $registrationHost = ''; - $confirmationHost = ''; - - if ($registration != $defaultIp) { - $registrationHost = gethostbyaddr($registration); - } - if ($confirmation != $defaultIp) { - $confirmationHost = gethostbyaddr($confirmation); - } - - $information = $repository->getUserData($user); + $information = $repository->getUserData($user); return view( 'admin.users.show', compact( - 'title', 'mainTitleIcon', 'subTitle', 'subTitleIcon', 'information', - 'user', 'registration', 'confirmation', 'registrationHost', 'confirmationHost' + 'title', 'mainTitleIcon', 'subTitle', 'subTitleIcon', 'information', 'user' ) ); } diff --git a/app/Http/Controllers/Auth/ConfirmationController.php b/app/Http/Controllers/Auth/ConfirmationController.php deleted file mode 100644 index 3221971227..0000000000 --- a/app/Http/Controllers/Auth/ConfirmationController.php +++ /dev/null @@ -1,90 +0,0 @@ -data; - $time = Preferences::get('user_confirmed_last_mail', 0)->data; - $now = time(); - $maxDiff = config('firefly.confirmation_age'); - - if ($database === $code && ($now - $time <= $maxDiff)) { - - // trigger user registration event: - event(new ConfirmedUser(auth()->user(), $request->ip())); - - Preferences::setForUser(auth()->user(), 'user_confirmed', true); - Preferences::setForUser(auth()->user(), 'user_confirmed_confirmed', time()); - Session::flash('success', strval(trans('firefly.account_is_confirmed'))); - - return redirect(route('home')); - } - throw new FireflyException(trans('firefly.invalid_activation_code')); - } - - /** - * @param Request $request - * - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View - */ - public function resendConfirmation(Request $request) - { - $time = Preferences::get('user_confirmed_last_mail', 0)->data; - $now = time(); - $maxDiff = config('firefly.resend_confirmation'); - $owner = env('SITE_OWNER', 'mail@example.com'); - $view = 'auth.confirmation.no-resent'; - if ($now - $time > $maxDiff) { - event(new ResentConfirmation(auth()->user(), $request->ip())); - $view = 'auth.confirmation.resent'; - } - - return view($view, ['owner' => $owner]); - } - -} diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 53b352a516..097d912855 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -98,9 +98,6 @@ class RegisterController extends Controller $user = $this->create($request->all()); // trigger user registration event: - // automatically activate user: - Preferences::setForUser($user, 'user_confirmed', true); - Preferences::setForUser($user, 'user_confirmed_last_mail', 0); event(new RegisteredUser($user, $request->ip())); Auth::login($user); @@ -125,9 +122,6 @@ class RegisterController extends Controller // is demo site? $isDemoSite = FireflyConfig::get('is_demo_site', Config::get('firefly.configuration.is_demo_site'))->data; - // activate account? - $mustConfirmAccount = FireflyConfig::get('must_confirm_account', Config::get('firefly.configuration.must_confirm_account'))->data; - // is allowed to? $singleUserMode = FireflyConfig::get('single_user_mode', Config::get('firefly.configuration.single_user_mode'))->data; $userCount = User::count(); @@ -139,7 +133,7 @@ class RegisterController extends Controller $email = $request->old('email'); - return view('auth.register', compact('isDemoSite', 'email', 'mustConfirmAccount')); + return view('auth.register', compact('isDemoSite', 'email')); } /** diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 1abee2e11b..bfa7f86356 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -175,9 +175,6 @@ class HomeController extends Controller 'logout', 'two-fac', 'lost-two', - 'confirm', - 'resend', - 'do_confirm', // test troutes 'test-flash', 'all-routes', diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index b9f1190f10..e8dc229028 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -17,8 +17,6 @@ use FireflyIII\Http\Middleware\AuthenticateTwoFactor; use FireflyIII\Http\Middleware\Binder; use FireflyIII\Http\Middleware\EncryptCookies; use FireflyIII\Http\Middleware\IsAdmin; -use FireflyIII\Http\Middleware\IsConfirmed; -use FireflyIII\Http\Middleware\IsNotConfirmed; use FireflyIII\Http\Middleware\Range; use FireflyIII\Http\Middleware\RedirectIfAuthenticated; use FireflyIII\Http\Middleware\RedirectIfTwoFactorAuthenticated; @@ -124,7 +122,6 @@ class Kernel extends HttpKernel SubstituteBindings::class, Authenticate::class, AuthenticateTwoFactor::class, - IsNotConfirmed::class, ], // MUST be logged in @@ -153,7 +150,6 @@ class Kernel extends HttpKernel SubstituteBindings::class, Authenticate::class, AuthenticateTwoFactor::class, - IsConfirmed::class, Range::class, Binder::class, ], @@ -171,11 +167,9 @@ class Kernel extends HttpKernel SubstituteBindings::class, Authenticate::class, AuthenticateTwoFactor::class, - IsConfirmed::class, IsAdmin::class, Range::class, Binder::class, - ], diff --git a/app/Http/Middleware/IsAdmin.php b/app/Http/Middleware/IsAdmin.php index 598de92d86..823be2f20d 100644 --- a/app/Http/Middleware/IsAdmin.php +++ b/app/Http/Middleware/IsAdmin.php @@ -26,8 +26,7 @@ use Illuminate\Support\Facades\Auth; class IsAdmin { /** - * Handle an incoming request. User account must be confirmed for this routine to let - * the user pass. + * Handle an incoming request. Must be admin. * * @param \Illuminate\Http\Request $request * @param \Closure $next diff --git a/app/Http/Middleware/IsConfirmed.php b/app/Http/Middleware/IsConfirmed.php deleted file mode 100644 index 1f53e2f41a..0000000000 --- a/app/Http/Middleware/IsConfirmed.php +++ /dev/null @@ -1,67 +0,0 @@ -guest()) { - if ($request->ajax()) { - return response('Unauthorized.', 401); - } - - return redirect()->guest('login'); - } - // must the user be confirmed in the first place? - $confirmPreference = FireflyConfig::get('must_confirm_account', config('firefly.configuration.must_confirm_account')); - $mustConfirmAccount = false; - if (!is_null($confirmPreference)) { - $mustConfirmAccount = $confirmPreference->data; - } - - // user must be logged in, then continue: - $isConfirmed = Preferences::get('user_confirmed', false)->data; - - if ($isConfirmed === false && $mustConfirmAccount === true) { - - // user account is not confirmed, redirect to - // confirmation page: - return redirect(route('confirmation_error')); - } - - return $next($request); - } -} diff --git a/app/Http/Middleware/IsNotConfirmed.php b/app/Http/Middleware/IsNotConfirmed.php deleted file mode 100644 index 0037c00e7a..0000000000 --- a/app/Http/Middleware/IsNotConfirmed.php +++ /dev/null @@ -1,64 +0,0 @@ -guest()) { - if ($request->ajax()) { - return response('Unauthorized.', 401); - } - - return redirect()->guest('login'); - } - // must the user be confirmed in the first place? - $mustConfirmAccount = FireflyConfig::get('must_confirm_account', config('firefly.configuration.must_confirm_account'))->data; - Log::debug(sprintf('mustConfirmAccount is %s', $mustConfirmAccount)); - // user must be logged in, then continue: - $isConfirmed = Preferences::get('user_confirmed', false)->data; - Log::debug(sprintf('isConfirmed is %s', $isConfirmed)); - if ($isConfirmed || $mustConfirmAccount === false) { - Log::debug('User is confirmed or user does not have to confirm account. Redirect home.'); - - // user account is confirmed, simply send them home. - return redirect(route('home')); - } - - return $next($request); - } -} diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index b99510ed99..61e41f8342 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -45,10 +45,6 @@ class EventServiceProvider extends ServiceProvider 'FireflyIII\Events\RequestedNewPassword' => [ // is a User related event. 'FireflyIII\Handlers\Events\UserEventHandler@sendNewPassword', ], - 'FireflyIII\Events\ResentConfirmation' => // is a User related event. - [ - 'FireflyIII\Handlers\Events\UserEventHandler@sendConfirmationMessageAgain', - ], 'FireflyIII\Events\StoredBudgetLimit' => // is a Budget related event. [ 'FireflyIII\Handlers\Events\BudgetEventHandler@storeRepetition', diff --git a/app/Repositories/User/UserRepository.php b/app/Repositories/User/UserRepository.php index 5c2c567357..c0e8cac992 100644 --- a/app/Repositories/User/UserRepository.php +++ b/app/Repositories/User/UserRepository.php @@ -108,14 +108,6 @@ class UserRepository implements UserRepositoryInterface $return['has_2fa'] = true; } - // is user activated? - $mustConfirmAccount = FireflyConfig::get('must_confirm_account', config('firefly.configuration.must_confirm_account'))->data; - $isConfirmed = Preferences::getForUser($user, 'user_confirmed', false)->data; - $return['is_activated'] = true; - if ($isConfirmed === false && $mustConfirmAccount === true) { - $return['is_activated'] = false; - } - $return['is_admin'] = $user->hasRole('owner'); $return['blocked'] = intval($user->blocked) === 1; $return['blocked_code'] = $user->blocked_code; diff --git a/app/Support/Events/SendUserMail.php b/app/Support/Events/SendUserMail.php deleted file mode 100644 index 59a1ebc66c..0000000000 --- a/app/Support/Events/SendUserMail.php +++ /dev/null @@ -1,62 +0,0 @@ -data; - if ($mustConfirmAccount === false) { - Preferences::setForUser($user, 'user_confirmed', true); - Preferences::setForUser($user, 'user_confirmed_last_mail', 0); - Preferences::mark(); - - return true; - } - $email = $user->email; - $code = str_random(16); - $route = route('do_confirm_account', [$code]); - Preferences::setForUser($user, 'user_confirmed', false); - Preferences::setForUser($user, 'user_confirmed_last_mail', time()); - Preferences::setForUser($user, 'user_confirmed_code', $code); - try { - Mail::send( - ['emails.confirm-account-html', 'emails.confirm-account-text'], ['route' => $route, 'ip' => $ipAddress], - function (Message $message) use ($email) { - $message->to($email, $email)->subject('Please confirm your Firefly III account'); - } - ); - } catch (Swift_TransportException $e) { - Log::error($e->getMessage()); - } catch (Exception $e) { - Log::error($e->getMessage()); - } - - return true; - } -} \ No newline at end of file diff --git a/resources/views/admin/configuration/index.twig b/resources/views/admin/configuration/index.twig index 6e16910a07..a3a15e629b 100644 --- a/resources/views/admin/configuration/index.twig +++ b/resources/views/admin/configuration/index.twig @@ -24,20 +24,6 @@ - {# need to activate account #} -
-
-
-

{{ 'setting_must_confirm_account'|_ }}

-
-
-

- {{ 'setting_must_confirm_account_explain'|_ }} -

- {{ ExpandedForm.checkbox('must_confirm_account','1', mustConfirmAccount) }} -
-
-
{# installation is demo site #}
diff --git a/resources/views/admin/users/show.twig b/resources/views/admin/users/show.twig index 38794f32c2..2922ed89ff 100644 --- a/resources/views/admin/users/show.twig +++ b/resources/views/admin/users/show.twig @@ -28,14 +28,6 @@ {{ user.created_at.formatLocalized(monthAndDayFormat) }} {{ user.created_at.format('H:i') }} - - {{ trans('list.registered_from') }} - {{ registration }} ({{ registrationHost }}) - - - {{ trans('list.confirmed_from') }} - {{ confirmation }} ({{ confirmationHost }}) - {{ trans('list.is_admin') }} @@ -56,16 +48,6 @@ {% endif %} - - {{ trans('list.is_activated') }} - - {% if information.is_activated %} - Yes - {% else %} - No - {% endif %} - - {{ trans('list.is_blocked') }} diff --git a/resources/views/auth/register.twig b/resources/views/auth/register.twig index c531e09733..30431d4763 100644 --- a/resources/views/auth/register.twig +++ b/resources/views/auth/register.twig @@ -27,10 +27,6 @@
- {% if mustConfirmAccount %} -

- You must activate your account. If your email address is incorrect, your account will not work.

- {% endif %}
diff --git a/routes/web.php b/routes/web.php index ba46a250d9..f78f062798 100755 --- a/routes/web.php +++ b/routes/web.php @@ -49,6 +49,7 @@ Route::group( /** * For the two factor routes, the user must be logged in, but NOT 2FA. Account confirmation does not matter here. + * @deprecated */ Route::group( ['middleware' => 'user-logged-in-no-2fa', 'prefix' => 'two-factor', 'as' => 'two-factor.', 'namespace' => 'Auth'], function () { @@ -59,18 +60,6 @@ Route::group( } ); -/** - * For the confirmation routes, the user must be logged in, also 2FA, but his account must not be confirmed. - */ -Route::group( - ['middleware' => 'user-logged-in-2fa-no-activation', 'namespace' => 'Auth'], function () { - Route::get('/confirm-your-account', ['uses' => 'ConfirmationController@confirmationError', 'as' => 'confirmation_error']); - Route::get('/resend-confirmation', ['uses' => 'ConfirmationController@resendConfirmation', 'as' => 'resend_confirmation']); - Route::get('/confirmation/{code}', ['uses' => 'ConfirmationController@doConfirmation', 'as' => 'do_confirm_account']); - -} -); - /** * For all other routes, the user must be fully authenticated and have an activated account. */