2016-08-03 13:57:01 -05:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* UserSaveIpAddress.php
|
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
|
|
*
|
2016-10-04 23:52:15 -05:00
|
|
|
* This software may be modified and distributed under the terms of the
|
|
|
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
|
|
|
*
|
|
|
|
* See the LICENSE file for details.
|
2016-08-03 13:57:01 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types = 1);
|
|
|
|
|
|
|
|
namespace FireflyIII\Handlers\Events;
|
|
|
|
|
|
|
|
use FireflyIII\Events\UserIsConfirmed;
|
|
|
|
use FireflyIII\Events\UserRegistration;
|
|
|
|
use Preferences;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class UserSaveIpAddress
|
|
|
|
*
|
|
|
|
* @package FireflyIII\Handlers\Events
|
|
|
|
*/
|
|
|
|
class UserSaveIpAddress
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Create the event listener.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the event.
|
|
|
|
*
|
2016-08-26 01:21:31 -05:00
|
|
|
* @param UserIsConfirmed $event
|
2016-08-03 13:57:01 -05:00
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2016-08-26 01:21:31 -05:00
|
|
|
public function saveFromConfirmation(UserIsConfirmed $event): bool
|
2016-08-03 13:57:01 -05:00
|
|
|
{
|
2016-08-26 01:21:31 -05:00
|
|
|
Preferences::setForUser($event->user, 'confirmation_ip_address', $event->ipAddress);
|
2016-08-03 13:57:01 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the event.
|
|
|
|
*
|
2016-08-26 01:21:31 -05:00
|
|
|
* @param UserRegistration $event
|
2016-08-03 13:57:01 -05:00
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2016-08-26 01:21:31 -05:00
|
|
|
public function saveFromRegistration(UserRegistration $event): bool
|
2016-08-03 13:57:01 -05:00
|
|
|
{
|
2016-08-26 01:21:31 -05:00
|
|
|
Preferences::setForUser($event->user, 'registration_ip_address', $event->ipAddress);
|
2016-08-03 13:57:01 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-08-12 08:10:03 -05:00
|
|
|
}
|