mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Admin view will show some IP addresses.
Signed-off-by: James Cole <thegrumpydictator@gmail.com>
This commit is contained in:
40
app/Events/UserIsConfirmed.php
Normal file
40
app/Events/UserIsConfirmed.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* UserIsConfirmed.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Events;
|
||||||
|
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class UserIsConfirmed
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Events
|
||||||
|
*/
|
||||||
|
class UserIsConfirmed extends Event
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
public $ipAddress;
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param User $user
|
||||||
|
* @param string $ipAddress
|
||||||
|
*/
|
||||||
|
public function __construct(User $user, string $ipAddress)
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
$this->ipAddress = $ipAddress;
|
||||||
|
}
|
||||||
|
}
|
62
app/Handlers/Events/UserSaveIpAddress.php
Normal file
62
app/Handlers/Events/UserSaveIpAddress.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* UserSaveIpAddress.php
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms
|
||||||
|
* of the MIT license. See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Handlers\Events;
|
||||||
|
|
||||||
|
use FireflyIII\Events\UserIsConfirmed;
|
||||||
|
use FireflyIII\Events\UserRegistration;
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Preferences;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class UserSaveIpAddress
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Handlers\Events
|
||||||
|
*/
|
||||||
|
class UserSaveIpAddress
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param UserRegistration $event
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function saveFromRegistration(UserRegistration $event): bool
|
||||||
|
{
|
||||||
|
Preferences::setForUser($event->user, 'registration_ip_address', $event->ipAddress);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param UserIsConfirmed $event
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function saveFromConfirmation(UserIsConfirmed $event): bool
|
||||||
|
{
|
||||||
|
Preferences::setForUser($event->user, 'confirmation_ip_address', $event->ipAddress);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@@ -13,6 +13,7 @@ namespace FireflyIII\Http\Controllers\Auth;
|
|||||||
|
|
||||||
use Auth;
|
use Auth;
|
||||||
use FireflyIII\Events\ResendConfirmation;
|
use FireflyIII\Events\ResendConfirmation;
|
||||||
|
use FireflyIII\Events\UserIsConfirmed;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -36,12 +37,13 @@ class ConfirmationController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $code
|
* @param Request $request
|
||||||
|
* @param string $code
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function doConfirmation(string $code)
|
public function doConfirmation(Request $request, string $code)
|
||||||
{
|
{
|
||||||
// check user_confirmed_last_mail
|
// check user_confirmed_last_mail
|
||||||
|
|
||||||
@@ -51,6 +53,10 @@ class ConfirmationController extends Controller
|
|||||||
$maxDiff = config('firefly.confirmation_age');
|
$maxDiff = config('firefly.confirmation_age');
|
||||||
|
|
||||||
if ($database === $code && ($now - $time <= $maxDiff)) {
|
if ($database === $code && ($now - $time <= $maxDiff)) {
|
||||||
|
|
||||||
|
// trigger user registration event:
|
||||||
|
event(new UserIsConfirmed(Auth::user(), $request->ip()));
|
||||||
|
|
||||||
Preferences::setForUser(Auth::user(), 'user_confirmed', true);
|
Preferences::setForUser(Auth::user(), 'user_confirmed', true);
|
||||||
Preferences::setForUser(Auth::user(), 'user_confirmed_confirmed', time());
|
Preferences::setForUser(Auth::user(), 'user_confirmed_confirmed', time());
|
||||||
Session::flash('success', strval(trans('firefly.account_is_confirmed')));
|
Session::flash('success', strval(trans('firefly.account_is_confirmed')));
|
||||||
|
@@ -62,6 +62,10 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
'FireflyIII\Handlers\Events\SendRegistrationMail',
|
'FireflyIII\Handlers\Events\SendRegistrationMail',
|
||||||
'FireflyIII\Handlers\Events\AttachUserRole',
|
'FireflyIII\Handlers\Events\AttachUserRole',
|
||||||
'FireflyIII\Handlers\Events\UserConfirmation@sendConfirmation',
|
'FireflyIII\Handlers\Events\UserConfirmation@sendConfirmation',
|
||||||
|
'FireflyIII\Handlers\Events\UserSaveIpAddress@saveFromRegistration',
|
||||||
|
],
|
||||||
|
'FireflyIII\Events\UserIsConfirmed' => [
|
||||||
|
'FireflyIII\Handlers\Events\UserSaveIpAddress@saveFromConfirmation',
|
||||||
],
|
],
|
||||||
'FireflyIII\Events\ResendConfirmation' => [
|
'FireflyIII\Events\ResendConfirmation' => [
|
||||||
'FireflyIII\Handlers\Events\UserConfirmation@resendConfirmation',
|
'FireflyIII\Handlers\Events\UserConfirmation@resendConfirmation',
|
||||||
|
@@ -142,6 +142,7 @@ return [
|
|||||||
'Route',
|
'Route',
|
||||||
'Auth',
|
'Auth',
|
||||||
'Lang',
|
'Lang',
|
||||||
|
'Preferences',
|
||||||
'URL',
|
'URL',
|
||||||
'Config',
|
'Config',
|
||||||
'ExpandedForm' => [
|
'ExpandedForm' => [
|
||||||
|
@@ -58,6 +58,8 @@ return [
|
|||||||
'is_blocked' => 'Is blocked',
|
'is_blocked' => 'Is blocked',
|
||||||
'is_admin' => 'Is admin',
|
'is_admin' => 'Is admin',
|
||||||
'has_two_factor' => 'Has 2FA',
|
'has_two_factor' => 'Has 2FA',
|
||||||
|
'confirmed_from' => 'Confirmed from',
|
||||||
|
'registered_from' => 'Registered from',
|
||||||
'blocked_code' => 'Block code',
|
'blocked_code' => 'Block code',
|
||||||
'domain' => 'Domain',
|
'domain' => 'Domain',
|
||||||
'registration_attempts' => 'Registration attempts',
|
'registration_attempts' => 'Registration attempts',
|
||||||
|
@@ -17,6 +17,8 @@
|
|||||||
<th colspan="2"> </th>
|
<th colspan="2"> </th>
|
||||||
<th>{{ trans('list.email') }}</th>
|
<th>{{ trans('list.email') }}</th>
|
||||||
<th>{{ trans('list.registered_at') }}</th>
|
<th>{{ trans('list.registered_at') }}</th>
|
||||||
|
<th>{{ trans('list.registered_from') }}</th>
|
||||||
|
<th>{{ trans('list.confirmed_from') }}</th>
|
||||||
<th>{{ trans('list.is_admin') }}</th>
|
<th>{{ trans('list.is_admin') }}</th>
|
||||||
<th>{{ trans('list.has_two_factor') }}</th>
|
<th>{{ trans('list.has_two_factor') }}</th>
|
||||||
<th>{{ trans('list.is_activated') }}</th>
|
<th>{{ trans('list.is_activated') }}</th>
|
||||||
@@ -34,6 +36,12 @@
|
|||||||
{{ user.created_at.formatLocalized(monthAndDayFormat) }}
|
{{ user.created_at.formatLocalized(monthAndDayFormat) }}
|
||||||
{{ user.created_at.format('H:i') }}
|
{{ user.created_at.format('H:i') }}
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ Preferences.getForUser(user,"registration_ip_address").data }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ Preferences.getForUser(user,"confirmation_ip_address").data }}
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if user.isAdmin %}
|
{% if user.isAdmin %}
|
||||||
<small class="text-success"><i class="fa fa-fw fa-check"></i></small>
|
<small class="text-success"><i class="fa fa-fw fa-check"></i></small>
|
||||||
|
Reference in New Issue
Block a user