Personal data and password change

This commit is contained in:
2026-04-26 01:15:58 +02:00
parent f4ea07d82c
commit 5bcdc2fb5d
20 changed files with 620 additions and 26 deletions

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Domains\UserManagement\Controllers;
use App\Providers\InertiaProvider;
use App\Scopes\CommonController;
class ProfileController extends CommonController
{
public function __invoke()
{
if (!$this->checkAuth()) {
return redirect()->intended('/login');
}
$user = auth()->user();
$inertiaProvider = new InertiaProvider('UserManagement/Profile', [
'username' => $user->username,
]);
return $inertiaProvider->render();
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Domains\UserManagement\Controllers;
use App\Domains\UserManagement\Actions\UserChangePassword\UserChangePasswordCommand;
use App\Domains\UserManagement\Actions\UserChangePassword\UserChangePasswordRequest;
use App\Scopes\CommonController;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class StoreProfileController extends CommonController
{
public function __invoke(Request $request): JsonResponse
{
if (!$this->checkAuth()) {
return response()->json(['success' => false, 'message' => 'Unauthorized'], 401);
}
$password = $request->input('password');
$passwordConfirmation = $request->input('password_confirmation');
if (empty($password)) {
return response()->json(['success' => false, 'message' => 'Bitte ein Passwort eingeben.'], 422);
}
if ($password !== $passwordConfirmation) {
return response()->json(['success' => false, 'message' => 'Die Passwörter stimmen nicht überein.'], 422);
}
$actionRequest = new UserChangePasswordRequest(auth()->user(), $password);
$command = new UserChangePasswordCommand($actionRequest);
$command->execute();
auth()->logout();
return response()->json(['success' => true, 'message' => 'Dein Passwort wurde erfolgreich geändert.']);
}
}