2222use phpMyFAQ \Administration \Report ;
2323use phpMyFAQ \Auth ;
2424use phpMyFAQ \Category ;
25- use phpMyFAQ \Controller \AbstractController ;
2625use phpMyFAQ \Core \Exception ;
26+ use phpMyFAQ \Enums \AdminLogType ;
2727use phpMyFAQ \Enums \PermissionType ;
2828use phpMyFAQ \Filter ;
2929use phpMyFAQ \Helper \MailHelper ;
4040use Symfony \Component \Mailer \Exception \TransportExceptionInterface ;
4141use Symfony \Component \Routing \Attribute \Route ;
4242
43- final class UserController extends AbstractController
43+ final class UserController extends AbstractAdministrationApiController
4444{
4545 /**
4646 * @throws Exception
@@ -102,7 +102,6 @@ public function csvExport(): Response
102102 ['ID ' , 'Status ' , 'Super Admin ' , 'Visible ' , 'Display Name ' , 'Username ' , 'Email ' , 'Auth Source ' ],
103103 separator: ', ' ,
104104 enclosure: '" ' ,
105- escape: '\\' ,
106105 eol: PHP_EOL ,
107106 );
108107
@@ -122,7 +121,6 @@ public function csvExport(): Response
122121 ],
123122 separator: ', ' ,
124123 enclosure: '" ' ,
125- escape: '\\' ,
126124 eol: PHP_EOL ,
127125 );
128126 }
@@ -208,6 +206,7 @@ public function activate(Request $request): JsonResponse
208206 $ currentUser ->getUserById ((int ) $ userId , allowBlockedUsers: true );
209207 try {
210208 if ($ currentUser ->activateUser ()) {
209+ $ this ->adminLog ->log ($ this ->currentUser , AdminLogType::USER_EDIT ->value . ' (activated): ' . $ userId );
211210 return $ this ->json (['success ' => $ currentUser ->getStatus ()], Response::HTTP_OK );
212211 }
213212
@@ -254,6 +253,8 @@ public function overwritePassword(Request $request): JsonResponse
254253 return $ this ->json (['error ' => Translation::get (key: 'ad_passwd_fail ' )], Response::HTTP_BAD_REQUEST );
255254 }
256255
256+ $ this ->adminLog ->log ($ this ->currentUser , AdminLogType::USER_CHANGE_PASSWORD ->value . ': ' . $ userId );
257+
257258 return $ this ->json (['success ' => Translation::get (key: 'ad_passwdsuc ' )], Response::HTTP_OK );
258259 }
259260
@@ -300,6 +301,8 @@ public function deleteUser(Request $request): JsonResponse
300301 $ permissions ->removeFromAllGroups ($ userId );
301302 }
302303
304+ $ this ->adminLog ->log ($ this ->currentUser , AdminLogType::USER_DELETE ->value . ': ' . $ userId );
305+
303306 return $ this ->json (['success ' => Translation::get (key: 'ad_user_deleted ' )], Response::HTTP_OK );
304307 }
305308
@@ -374,6 +377,8 @@ public function addUser(Request $request): JsonResponse
374377 /* @mago-expect lint:no-empty-catch-clause */
375378 }
376379
380+ $ this ->adminLog ->log ($ this ->currentUser , AdminLogType::USER_ADD ->value . ': ' . $ newUser ->getUserId ());
381+
377382 return $ this ->json (['success ' => Translation::get (key: 'ad_adus_suc ' )], Response::HTTP_OK );
378383 }
379384
@@ -433,6 +438,8 @@ public function editUser(Request $request): JsonResponse
433438 return $ this ->json (['error ' => 'ad_msg_mysqlerr ' ], Response::HTTP_BAD_REQUEST );
434439 }
435440
441+ $ this ->adminLog ->log ($ this ->currentUser , AdminLogType::USER_EDIT ->value . ': ' . $ userId );
442+
436443 $ success =
437444 Translation::get (key: 'ad_msg_savedsuc_1 ' )
438445 . ' " '
@@ -478,6 +485,8 @@ public function updateUserRights(Request $request): JsonResponse
478485 $ user ->perm ->grantUserRight ($ userId , (int ) $ userRight );
479486 }
480487
488+ $ this ->adminLog ->log ($ this ->currentUser , AdminLogType::USER_CHANGE_PERMISSIONS ->value . ': ' . $ userId );
489+
481490 $ user ->terminateSessionId ();
482491 $ success =
483492 Translation::get (key: 'ad_msg_savedsuc_1 ' )
0 commit comments