mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
Removed deprecated event and handlers. (block use of email and deleted user)
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* BlockedUseOfEmail.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Events;
|
||||
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class BlockedUseOfEmail
|
||||
*
|
||||
* @deprecated
|
||||
* @package FireflyIII\Events
|
||||
*/
|
||||
class BlockedUseOfEmail extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public $email;
|
||||
public $ipAddress;
|
||||
|
||||
/**
|
||||
* Create a new event instance. This event is triggered when a user tries to register with a banned email address (already used before).
|
||||
*
|
||||
* @param string $email
|
||||
* @param string $ipAddress
|
||||
*/
|
||||
public function __construct(string $email, string $ipAddress)
|
||||
{
|
||||
$this->email = $email;
|
||||
$this->ipAddress = $ipAddress;
|
||||
}
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* DeletedUser.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class DeletedUser
|
||||
*
|
||||
* @deprecated
|
||||
* @package FireflyIII\Events
|
||||
*/
|
||||
class DeletedUser extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
public $email;
|
||||
|
||||
/**
|
||||
* Create a new event instance. This event is triggered when a user deletes themselves.
|
||||
*
|
||||
* @param string $email
|
||||
*/
|
||||
public function __construct(string $email)
|
||||
{
|
||||
$this->email = $email;
|
||||
}
|
||||
}
|
@@ -15,9 +15,7 @@ namespace FireflyIII\Handlers\Events;
|
||||
|
||||
use Exception;
|
||||
use FireflyConfig;
|
||||
use FireflyIII\Events\BlockedUseOfEmail;
|
||||
use FireflyIII\Events\ConfirmedUser;
|
||||
use FireflyIII\Events\DeletedUser;
|
||||
use FireflyIII\Events\RegisteredUser;
|
||||
use FireflyIII\Events\RequestedNewPassword;
|
||||
use FireflyIII\Events\ResentConfirmation;
|
||||
@@ -79,70 +77,6 @@ class UserEventHandler
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BlockedUseOfEmail $event
|
||||
*
|
||||
* @deprecated
|
||||
* @return bool
|
||||
*/
|
||||
public function reportUseOfBlockedEmail(BlockedUseOfEmail $event): bool
|
||||
{
|
||||
$email = $event->email;
|
||||
$owner = env('SITE_OWNER');
|
||||
$ipAddress = $event->ipAddress;
|
||||
/** @var Configuration $sendmail */
|
||||
$sendmail = FireflyConfig::get('mail_for_blocked_email', config('firefly.configuration.mail_for_blocked_email'));
|
||||
Log::debug(sprintf('Now in reportUseOfBlockedEmail for email address %s', $email));
|
||||
Log::error(sprintf('Somebody tried to register using email address %s which is blocked (SHA2 hash).', $email));
|
||||
if (is_null($sendmail) || (!is_null($sendmail) && $sendmail->data === false)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// send email message:
|
||||
try {
|
||||
Mail::send(
|
||||
['emails.blocked-email-html', 'emails.blocked-email-text'],
|
||||
[
|
||||
'user_address' => $email,
|
||||
'ip' => $ipAddress,
|
||||
], function (Message $message) use ($owner) {
|
||||
$message->to($owner, $owner)->subject('Blocked registration attempt with blocked email address');
|
||||
}
|
||||
);
|
||||
} catch (Swift_TransportException $e) {
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DeletedUser $event
|
||||
*
|
||||
* @deprecated
|
||||
* @return bool
|
||||
*/
|
||||
public function saveEmailAddress(DeletedUser $event): bool
|
||||
{
|
||||
Preferences::mark();
|
||||
$email = hash('sha256', $event->email);
|
||||
Log::debug(sprintf('Hash of email is %s', $email));
|
||||
/** @var Configuration $configuration */
|
||||
$configuration = FireflyConfig::get('deleted_users', []);
|
||||
$content = $configuration->data;
|
||||
if (!is_array($content)) {
|
||||
$content = [];
|
||||
}
|
||||
$content[] = $email;
|
||||
$configuration->data = $content;
|
||||
Log::debug('New content of deleted_users is ', $content);
|
||||
FireflyConfig::set('deleted_users', $content);
|
||||
|
||||
Preferences::mark();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will send a newly registered user a confirmation message, urging him or her to activate their account.
|
||||
*
|
||||
|
@@ -15,7 +15,6 @@ namespace FireflyIII\Http\Controllers\Auth;
|
||||
use Auth;
|
||||
use Config;
|
||||
use FireflyConfig;
|
||||
use FireflyIII\Events\BlockedUseOfEmail;
|
||||
use FireflyIII\Events\RegisteredUser;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\User;
|
||||
@@ -91,7 +90,6 @@ class RegisterController extends Controller
|
||||
Log::debug('Hashes of deleted users: ', $set);
|
||||
if (in_array($hash, $set)) {
|
||||
$validator->getMessageBag()->add('email', (string)trans('validation.deleted_user'));
|
||||
event(new BlockedUseOfEmail($data['email'], $request->ip()));
|
||||
$this->throwValidationException($request, $validator);
|
||||
}
|
||||
|
||||
|
@@ -41,16 +41,6 @@ class EventServiceProvider extends ServiceProvider
|
||||
[
|
||||
'FireflyIII\Handlers\Events\UserEventHandler@storeConfirmationIpAddress',
|
||||
],
|
||||
|
||||
'FireflyIII\Events\DeletedUser' => // is a User related event.
|
||||
[
|
||||
'FireflyIII\Handlers\Events\UserEventHandler@saveEmailAddress',
|
||||
],
|
||||
|
||||
'FireflyIII\Events\BlockedUseOfEmail' => // is a User related event.
|
||||
[
|
||||
'FireflyIII\Handlers\Events\UserEventHandler@reportUseOfBlockedEmail',
|
||||
],
|
||||
'FireflyIII\Events\RegisteredUser' => // is a User related event.
|
||||
[
|
||||
'FireflyIII\Handlers\Events\UserEventHandler@sendRegistrationMail',
|
||||
|
@@ -15,7 +15,6 @@ namespace FireflyIII\Repositories\User;
|
||||
|
||||
|
||||
use FireflyConfig;
|
||||
use FireflyIII\Events\DeletedUser;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Models\Role;
|
||||
use FireflyIII\User;
|
||||
@@ -69,14 +68,9 @@ class UserRepository implements UserRepositoryInterface
|
||||
*/
|
||||
public function destroy(User $user): bool
|
||||
{
|
||||
$email = $user->email;
|
||||
Log::debug(sprintf('Calling delete() on user %d', $user->id));
|
||||
$user->delete();
|
||||
|
||||
|
||||
// trigger event:
|
||||
event(new DeletedUser($email));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -1,5 +0,0 @@
|
||||
{% include 'emails.header-html' %}
|
||||
<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">
|
||||
Firefly III has just blocked a registration for email addres "{{ email_address }}". It was used before.
|
||||
</p>
|
||||
{% include 'emails.footer-html' %}
|
@@ -1,3 +0,0 @@
|
||||
{% include 'emails.header-text' %}
|
||||
Firefly III has just blocked a registration for email addres "{{ user_address }}". It was used before.
|
||||
{% include 'emails.footer-text' %}
|
Reference in New Issue
Block a user