Skip to content

feat: (LAR-86) add bannished sysem #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9647e17
feat: (LAR-107) Modification du formulaire de mot de passe oublié
Stephen2304 Nov 11, 2024
cd4c813
fix: (LAR-107) correction des conflits
Stephen2304 Nov 12, 2024
e3dfba4
feat: (LAR-107) Mise a jour
Stephen2304 Nov 11, 2024
583a633
feat: (LAR-107) Suppression des commentaire
Stephen2304 Nov 11, 2024
23882cf
fix: (LAR-107) suppresion du fichier auth-session
Stephen2304 Nov 11, 2024
a8cd309
fix: (LAR-107) correction des espaces
Stephen2304 Nov 12, 2024
374f8fa
feat: (LAR-86) add bannished sysem
StevyMarlino Nov 10, 2024
bf10e0c
feat(test): (LAR-86) add test
StevyMarlino Nov 12, 2024
9687fde
feat: (LAR-107) Authentification avec Breeze (#216)
Stephen2304 Nov 12, 2024
a602c5a
feat(test): (LAR-86) adding test for bannished user
StevyMarlino Nov 12, 2024
00009db
refact: (LAR-86) refactoring of the mail ban and unban
StevyMarlino Nov 12, 2024
c977b1c
fix: [LAR-116] publish scope on single tag articles list
mckenziearts Nov 12, 2024
4bd49e1
feat(translation): (LAR-86) add translation for UserResource
StevyMarlino Nov 12, 2024
af8674d
fix: [LAR-116] publish scope on single tag articles list (#220)
StevyMarlino Nov 12, 2024
6c2fe5b
fix (LAR-107) correction du fichier verify-email (#221)
Stephen2304 Nov 12, 2024
bc721e4
refactor: (LAR-86) refactoring test and translation 🥲
StevyMarlino Nov 13, 2024
13e5282
feat: (LAR-86) add bannished sysem
StevyMarlino Nov 10, 2024
10f30ba
feat(test): (LAR-86) add test
StevyMarlino Nov 12, 2024
a66589b
feat(test): (LAR-86) adding test for bannished user
StevyMarlino Nov 12, 2024
a2579b3
refact: (LAR-86) refactoring of the mail ban and unban
StevyMarlino Nov 12, 2024
23691c1
feat(translation): (LAR-86) add translation for UserResource
StevyMarlino Nov 12, 2024
7eef7be
refactor: (LAR-86) refactoring test and translation 🥲
StevyMarlino Nov 13, 2024
7cdf064
Merge branch 'feature/lar-86-mettre-en-place-un-systeme-pour-bannir-u…
StevyMarlino Nov 13, 2024
9133988
fix: (LAR-86) fixing phpstan error
StevyMarlino Nov 13, 2024
2a9af9a
fix: (LAR-86) fix testing error 500
StevyMarlino Nov 13, 2024
8c31f0f
Revert "fix: (LAR-86) fix testing error 500"
StevyMarlino Nov 13, 2024
3cd63fd
fix: (LAR-86) update test file
StevyMarlino Nov 13, 2024
381385f
fix(test): (LAR-86) fixing test bug
StevyMarlino Nov 13, 2024
8f64dc0
refact: (LAR-86) change key message ban
StevyMarlino Nov 13, 2024
a3633d7
feat: (LAR-86) improvement to Banning function
StevyMarlino Nov 13, 2024
02b039b
feat(test): (LAR-86) updating test and other file
StevyMarlino Nov 14, 2024
0c221dc
fix(pint): (LAR-86) fixing laravel pint format
StevyMarlino Nov 14, 2024
18eefd6
refact: (LAR-86) refactoring test email and other some files
StevyMarlino Nov 14, 2024
d6c731f
refact: (LAR-86) refactoring add ban migration
StevyMarlino Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions app/Filament/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@
->icon('untitledui-inbox')
->description(fn ($record): ?string => $record->phone_number),
Tables\Columns\TextColumn::make('email_verified_at')
->label('Validation Email')
->label(__('global.ban.label.validate_email'))
->placeholder('N/A')
->date(),
Tables\Columns\TextColumn::make(name: 'created_at')
->label('Inscription')
->label(__('global.ban.label.inscription'))
->date(),
])
->filters([
Tables\Filters\TernaryFilter::make('email_verified_at')
->label('Email Vérifiée')
->label(__('global.ban.label.email_verified'))
->nullable(),
])
->actions([
Expand All @@ -74,20 +74,20 @@
->icon('untitledui-archive')
->color('warning')
->visible(fn ($record) => $record->banned_at == null)
->modalHeading(__('Bannir l\'utilisateur'))
->modalDescription(__('Veuillez entrer la raison du bannissement.'))
->modalHeading(__('global.ban.heading'))
->modalDescription(__('global.ban.description'))
->form([

TextInput::make('banned_reason')
->label(__('Raison du bannissement'))
->label(__('global.ban.reason'))
->required(),
])
->action(function (User $record, array $data) {
if (!self::canBanUser($record)) {
Notification::make()
->warning()
->title(__('Impossible de bannir'))
->body(__('Vous ne pouvez pas bannir un administrateur.'))
->title(__('notifications.user.cannot.title'))
->body(__('notifications.user.cannot.ban_admin'))
->duration(5000)
->send();

Expand Down Expand Up @@ -121,27 +121,27 @@
];
}

public static function BanUserAction(User $record, $reason): void

Check failure on line 124 in app/Filament/Resources/UserResource.php

View workflow job for this annotation

GitHub Actions / phpstan

Method App\Filament\Resources\UserResource::BanUserAction() has parameter $reason with no type specified.
{
if ($record->banned_at !== null) {
Notification::make()
->warning()
->title(__('Impossible de bannir'))
->body(__('Cet utilisateur est déjà banni.'))
->title(__('notifications.user.cannot.title'))
->body(__('notifications.user.cannot.body'))
->send();

return;
}

$record->banned_at = Carbon::now();

Check failure on line 136 in app/Filament/Resources/UserResource.php

View workflow job for this annotation

GitHub Actions / phpstan

Property App\Models\User::$banned_at (Illuminate\Support\Carbon|null) does not accept Carbon\Carbon.
$record->banned_reason = $reason;
$record->save();

Notification::make()
->success()
->duration(5000)
->title(__('L\'utilisateur à été banni'))
->body(__('L\'utilisateur à été notifier qu\'il à été banni'))
->title(__('notifications.user.banned.title'))
->body(__('notifications.user.banned.body'))
->send();

event(new UserBannedEvent($record));
Expand All @@ -155,9 +155,9 @@

Notification::make()
->success()
->title(__('L\'utilisateur à été dé-banni'))
->title(__('notifications.user.unbanned.title'))
->duration(5000)
->body(__('L\'utilisateur à été notifier qu\'il peut de nouveau se connecter'))
->body(__('notifications.user.unbanned.body'))
->send();

event(new UserUnbannedEvent($record));
Expand Down
6 changes: 3 additions & 3 deletions app/Filament/Resources/UserResource/Pages/ListUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
public function getTabs() : array
{
return [
__('Tout') => Tab::make('Tout'),
__("Bannis") => Tab::make(__('Bannis'))
__('global.ban.all') => Tab::make(__('global.ban.all')),

Check failure on line 18 in app/Filament/Resources/UserResource/Pages/ListUsers.php

View workflow job for this annotation

GitHub Actions / phpstan

Possibly invalid array key type (array|string).
__('global.ban.banned') => Tab::make(__('global.ban.banned'))

Check failure on line 19 in app/Filament/Resources/UserResource/Pages/ListUsers.php

View workflow job for this annotation

GitHub Actions / phpstan

Possibly invalid array key type (array|string).
->modifyQueryUsing(function ($query) {
return $query->isBanned();
}),
__("Non Bannis") => Tab::make(__('Non Bannis'))
__('global.ban.not_banned') => Tab::make(__('global.ban.not_banned'))

Check failure on line 23 in app/Filament/Resources/UserResource/Pages/ListUsers.php

View workflow job for this annotation

GitHub Actions / phpstan

Possibly invalid array key type (array|string).
->modifyQueryUsing(function ($query) {
return $query->isNotBanned();
}),
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/CheckIfBanned.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function handle(Request $request, Closure $next): Response
Auth::logout();

return redirect()->route('login')->withErrors([
'email' => __('Votre compte a été banni. Contactez l\'administrateur pour plus d\'informations.'),
'email' => __('global.ban.message'),
]);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Mail/UserBannedEMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(public User $user){}
public function envelope(): Envelope
{
return new Envelope(
subject: __('Notification de bannissement Laravelcm'),
subject: __('global.ban.ban_email_subject'),
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Mail/UserUnBannedEMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(public User $user){}
public function envelope(): Envelope
{
return new Envelope(
subject: __('Notification de dé-baannissement Laravelcm'),
subject: __('global.ban.unban_email_subject'),
);
}

Expand Down
19 changes: 17 additions & 2 deletions lang/en/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,20 @@
'discussion_description' => 'Discuss and debate different themes and ideas',
],
'moderator' => 'Moderator',

];
'ban' => [
'reason' => 'Reason for banning',
'heading' => 'Ban the user',
'description' => 'Please enter the reason for banning.',
'all' => 'All',
'banned' => 'Banned',
'not_banned' => 'Not banned',
'ban_email_subject' => 'Laravelcm ban notification',
'unban_email_subject' => 'Laravelcm unbanning notification',
'message' => 'Your account has been banned. Contact the administrator for more information.',
'label' => [
'email_verified' => 'Email verified',
'inscription' => 'Inscription',
'validate_email' => 'Validation Email'
],
],
];
17 changes: 16 additions & 1 deletion lang/en/notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,19 @@

'error' => 'Oops! You\'ve got errors.',

];
'user' => [
'banned' => [
'title' => 'The user has been banned.',
'body' => 'The user has been notified that he has been banned'
],
'unbanned' => [
'title' => 'The user has been un-banned',
'body' => 'The user has been notified that he can log in again.'
],
'cannot' => [
'title' => 'Unable to ban',
'body' => 'This user is already banned.',
'ban_admin' => 'You cannot ban an administrator.',
]
]
];
18 changes: 17 additions & 1 deletion lang/fr/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,21 @@
'discussion_description' => 'Échangez, débattez sur différentes thématiques et idées.',
],
'moderator' => 'Modérateur',
'ban' => [
'reason' => 'Raison du bannissement',
'heading' => 'Bannir l\'utilisateur',
'description' => 'Veuillez entrer la raison du bannissement.',
'all' => 'Tout',
'banned' => 'Bannis',
'not_banned' => 'Non bannis',
'ban_email_subject' => 'Notification de bannissement Laravelcm',
'unban_email_subject' => 'Notification de dé-baannissement Laravelcm',
'message' => 'Votre compte a été banni. Contactez l\'administrateur pour plus d\'informations.',
'label' => [
'email_verified' => 'Email verified',
'inscription' => 'Inscription',
'validate_email' => 'Validation Email'
],
]

];
];
17 changes: 16 additions & 1 deletion lang/fr/notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,19 @@

'error' => 'Oups! Nous avons rencontré des erreurs.',

];
'user' => [
'banned' => [
'title' => 'L\'utilisateur à été banni.',
'body' => 'L\'utilisateur à été notifier qu\'il à été banni'
],
'unbanned' => [
'title' => 'L\'utilisateur à été dé-banni',
'body' => 'L\'utilisateur à été notifier qu\'il peut de nouveau se connecter'
],
'cannot' => [
'title' => 'Impossible de bannir',
'body' => 'Cet utilisateur est déjà banni.',
'ban_admin' => 'Vous ne pouvez pas bannir un administrateur.',
]
]
];
Loading