feat: add account unlock/lock notifications
This commit is contained in:
parent
a4f41b8f8d
commit
a265debe4c
61
app/Notifications/AccountLocked.php
Normal file
61
app/Notifications/AccountLocked.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class AccountLocked extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
return (new MailMessage)
|
||||
->from(config('notification.sender.address'), config('notification.sender.name'))
|
||||
->subject(config('app.name').' - account locked')
|
||||
->markdown('mail.account-locked', ['name' => $notifiable->name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
66
app/Notifications/AccountUnlocked.php
Normal file
66
app/Notifications/AccountUnlocked.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class AccountUnlocked extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
return (new MailMessage)
|
||||
->greeting('Hi ' . $notifiable->name . ',')
|
||||
->from(config('notification.sender.address'), config('notification.sender.name'))
|
||||
->subject(config('app.name').' - account unlocked')
|
||||
->line('We wanted to let you know that your account at ' . config('app.name') . ' is now unlocked. This means the circumstances surrounding your account\'s standing are now resolved.')
|
||||
->line('You can sign in and use the app normally again.')
|
||||
->line('If there\'s anything we can help you with, don\'t hesitate to reach out.')
|
||||
->action('Sign in', url(route('login')))
|
||||
->salutation('The team at ' . config('app.name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
@ -4,6 +4,8 @@
|
||||
namespace App\Services;
|
||||
|
||||
use App\Ban;
|
||||
use App\Notifications\AccountLocked;
|
||||
use App\Notifications\AccountUnlocked;
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@ -81,6 +83,8 @@ class AccountSuspensionService
|
||||
]);
|
||||
|
||||
$user->administratively_locked = 1;
|
||||
$user->notify(new AccountLocked);
|
||||
|
||||
return $user->save();
|
||||
}
|
||||
|
||||
@ -98,6 +102,8 @@ class AccountSuspensionService
|
||||
]);
|
||||
|
||||
$user->administratively_locked = 0;
|
||||
$user->notify(new AccountUnlocked);
|
||||
|
||||
return $user->save();
|
||||
}
|
||||
|
||||
|
18
resources/views/mail/account-locked.blade.php
Normal file
18
resources/views/mail/account-locked.blade.php
Normal file
@ -0,0 +1,18 @@
|
||||
@component('mail::message')
|
||||
# Hi {{ $name }},
|
||||
|
||||
We wanted to let you know that your account at {{ config('app.name') }} has been locked due to security concerns. Don't worry! You haven't been suspended! We lock accounts for a number of reasons, including, but not limited to:
|
||||
|
||||
- Suspicious activity was detected;
|
||||
- You failed to activate 2FA within the required timeframe;
|
||||
- Your password was detected on a 3rd party security breach;
|
||||
- You started an account deletion request;
|
||||
- Your password expired.
|
||||
|
||||
Please note that your account may be locked for reasons other than those listed above; If you think this was an error, please let us know, but keep in mind that this is an automated process and we can't manually unlock accounts. You will not be able to sign in or use the app while your account is locked.
|
||||
|
||||
Usually, you will receive another email with more information regarding your specific circumstances.
|
||||
|
||||
Thank you,<br>
|
||||
The team at {{ config('app.name') }}
|
||||
@endcomponent
|
Loading…
x
Reference in New Issue
Block a user