agb wip
This commit is contained in:
1 parent
18ce61bc9b
commit
76f4127bb2
8 files changed
+177
-64
No files matched your search
@@ -3,8 +3,11 @@
|
||||
namespace App\Filament\Resources\Users\Pages;
|
||||
|
||||
use App\Filament\Resources\Users\UserResource;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Schemas\Components\Section;
|
||||
|
||||
class ListUsers extends ListRecords
|
||||
{
|
||||
@@ -13,6 +16,34 @@ class ListUsers extends ListRecords
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('inviteUser')
|
||||
->label('Einladen')
|
||||
->icon('phosphor-envelope')
|
||||
->form([
|
||||
Section::make('Jemanden einladen')
|
||||
->icon('lucide-user')
|
||||
->description('Nur mit dieser Einladung können sich weitere Benutzer bei diesem Konto registrieren.')
|
||||
->schema([
|
||||
TextInput::make('email')
|
||||
->label('E-Mail')
|
||||
->prefixIcon('phosphor-envelope')
|
||||
->email()
|
||||
->required()
|
||||
->belowContent('Die Einladung ist 12 Stunden gültig.'),
|
||||
]),
|
||||
])
|
||||
->action(function ($data) {
|
||||
$invitation = Invitation::create([
|
||||
'knoto_id' => auth()->user()->konto_id,
|
||||
'email' => $data['email'],
|
||||
]);
|
||||
|
||||
// @todo Add email sending here
|
||||
|
||||
Notification::make('invitedSuccess')
|
||||
->body('Der Benutzer wurde erfolgreich eingelanden!')
|
||||
->success()->send();
|
||||
}),
|
||||
CreateAction::make()
|
||||
->icon('phosphor-file-plus')
|
||||
->createAnother(false)
|
||||
|
||||
@@ -21,15 +21,24 @@ class UserForm
|
||||
Section::make('Benutzerkonto')
|
||||
->icon('lucide-user')
|
||||
->schema([
|
||||
TextInput::make('name')->required(),
|
||||
Select::make('gender')
|
||||
->prefixIcon('phosphor-gender-neuter')
|
||||
->label('Geschlecht')
|
||||
->options([
|
||||
'Herr' => 'Herr',
|
||||
'Frau' => 'Frau',
|
||||
'Non-binary' => 'Non-binary',
|
||||
])
|
||||
->required(),
|
||||
TextInput::make('name')
|
||||
->prefixIcon('phosphor-user')
|
||||
->required(),
|
||||
TextInput::make('email')->email()
|
||||
->required()
|
||||
->prefixIcon('phosphor-envelope')
|
||||
->label('E-Mail'),
|
||||
]),
|
||||
Section::make('Sicherheit')
|
||||
->icon('lucide-lock')
|
||||
->schema([
|
||||
TextInput::make('password')
|
||||
->prefixIcon('phosphor-lock')
|
||||
->label('Passwort')
|
||||
->password() // Masks the input
|
||||
->required()
|
||||
@@ -38,19 +47,22 @@ class UserForm
|
||||
->dehydrateStateUsing(fn ($state) => bcrypt($state)) // Hashes the password before saving
|
||||
->label('Password'),
|
||||
TextInput::make('password_confirmation')
|
||||
->prefixIcon('phosphor-lock')
|
||||
->password() // Masks the input
|
||||
->required()
|
||||
->same('password') // Validates that this matches the 'password' field
|
||||
->label('Passwort Bestätigen'),
|
||||
Select::make('roles')
|
||||
->label('Rolle')
|
||||
->prefixIcon('phosphor-gear')
|
||||
->aboveContent('Nur für SuperAdmin sichtbare')
|
||||
->visible(fn () => auth()->user()->hasRole('super_admin'))
|
||||
->relationship('roles', 'name')
|
||||
->multiple()
|
||||
->preload()
|
||||
->searchable(),
|
||||
]),
|
||||
|
||||
Select::make('roles')
|
||||
->label('Rolle')
|
||||
->visible(fn () => auth()->user()->hasRole('super_admin'))
|
||||
->relationship('roles', 'name')
|
||||
->multiple()
|
||||
->preload()
|
||||
->searchable(),
|
||||
])->columns(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class AppUserAGBMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if ($request->user()->agb_akzeptiert == 0) {
|
||||
// return static::getResource()::getUrl('index');
|
||||
abort(Response::HTTP_FORBIDDEN, 'Bitte akzeptieren sie unsere AGBs.');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Invitation extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'konto_id',
|
||||
'email',
|
||||
'valid_hours_from_creation',
|
||||
];
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace App\Providers\Filament;
|
||||
|
||||
use Agencetwogether\HooksHelper\HooksHelperPlugin;
|
||||
use App\Filament\Pages\Auth\Register;
|
||||
use App\Http\Middleware\AppUserVerifiedMiddleware;
|
||||
use App\Http\Middleware\AppUserAGBMiddleware;
|
||||
use Awcodes\LightSwitch\Enums\Alignment;
|
||||
use Awcodes\LightSwitch\LightSwitchPlugin;
|
||||
use BezhanSalleh\FilamentShield\FilamentShieldPlugin;
|
||||
@@ -89,7 +89,7 @@ class AdminPanelProvider extends PanelProvider
|
||||
DispatchServingFilamentEvent::class,
|
||||
])
|
||||
->authMiddleware([
|
||||
AppUserVerifiedMiddleware::class,
|
||||
AppUserAGBMiddleware::class,
|
||||
Authenticate::class,
|
||||
])->plugins([
|
||||
FilamentShieldPlugin::make()
|
||||
|
||||
Reference in new issue
Block a user