remove codeigniter

This commit is contained in:
root
2026-06-04 02:41:08 -04:00
parent 4e33882ac7
commit b4e6ac03c5
180 changed files with 457 additions and 2186 deletions
@@ -11,8 +11,7 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
/**
* Mirrors CodeIgniter `AuthController::apiLogin` security behavior:
* IP lockout (ip_attempts), failed_attempts / suspension after 3 failures, login_activity logging.
* Centralizes API login lockout, suspension, and audit logging behavior.
*/
class ApiLoginSecurityService
{
@@ -79,7 +78,7 @@ class ApiLoginSecurityService
if ($failedAttempts >= 3) {
$data['is_suspended'] = true;
// CI sends reset email via View\UserController::sendResetEmail — wire Laravel mail here when parity is needed.
// Password-reset delivery can be wired here when the suspension workflow is finalized.
Log::notice('api_login: account suspended after failed attempts', ['email' => $email, 'user_id' => $user->id]);
}
@@ -113,7 +112,7 @@ class ApiLoginSecurityService
}
/**
* CI returns roles as an object map {"RoleName": true}.
* Returns roles as an object map {"RoleName": true}.
*
* @param list<string> $roleNames
*/
@@ -128,13 +127,13 @@ class ApiLoginSecurityService
}
/**
* Top-level JSON body aligned with the CodeIgniter 4 `AuthController::apiLogin` success payload.
* Top-level JSON body for API login success responses.
*
* @return array{status: true, token: string, user: array{id: int, name: string, roles: object, class_section_id: ?int, class_section_name: ?string}}
*/
public function buildLoginResponse(User $user, string $jwtToken): array
{
$roleNames = $user->roleNamesLikeCodeIgniter();
$roleNames = $user->roleNames();
$fullName = trim(($user->firstname ?? '').' '.($user->lastname ?? ''));
$teacherContext = $user->teacherSessionContext();
@@ -9,13 +9,14 @@ use App\Models\UserRole;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
use PHPOpenSourceSaver\JWTAuth\Facades\JWTAuth;
/**
* Matches CodeIgniter 4 `AuthController::apiRegister` (public API register, no captcha).
* Handles direct public API registration requests that bypass the captcha flow.
*/
class CodeIgniterApiRegistrationService
class ApiRegistrationService
{
public function registerResponse(Request $request): JsonResponse
{
@@ -115,7 +116,7 @@ class CodeIgniterApiRegistrationService
],
], 201);
} catch (\Throwable $e) {
log_message('error', 'Registration error: '.$e->getMessage());
Log::error('Registration error: '.$e->getMessage());
return response()->json([
'status' => false,
+8 -8
View File
@@ -13,7 +13,7 @@ use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
/**
* CodeIgniter `AuthController` web (session) flow: session keys, dashboards, redirects, preferences.
* Session-auth flow: session keys, dashboards, redirects, and preferences.
*/
class AuthSessionService
{
@@ -25,7 +25,7 @@ class AuthSessionService
}
/**
* Same-host relative redirect sanitization as CI `sanitizeRedirectTarget`.
* Sanitizes login redirects to same-host relative paths only.
*/
public function sanitizeRedirectTarget(string $redirectTo): ?string
{
@@ -84,7 +84,7 @@ class AuthSessionService
}
/**
* Apply CI-style preference keys into session (style/menu colors).
* Apply stored style preferences into the session.
*/
public function applyStylePreferencesToSession(int $userId): void
{
@@ -114,11 +114,11 @@ class AuthSessionService
}
/**
* Populate Laravel web auth + CI-compatible session keys.
* Populate Laravel web auth and session state for the web portal.
*
* @param list<string> $roleNames
*/
public function writeCiAuthenticatedSession(User $user, array $roleNames): void
public function writeAuthenticatedSession(User $user, array $roleNames): void
{
Auth::guard('web')->login($user);
@@ -145,7 +145,7 @@ class AuthSessionService
}
/**
* Close open login_activity row(s) without logout_time for this user (CI parity).
* Close open login_activity rows without logout_time for this user.
*/
public function logLogout(?int $userId, ?string $email): void
{
@@ -169,7 +169,7 @@ class AuthSessionService
*/
public function resolvePostLoginDestination(User $user, ?string $sanitizedRedirect): array
{
$roleNames = $user->roleNamesLikeCodeIgniter();
$roleNames = $user->roleNames();
if ($roleNames === []) {
Log::notice('session_login: user has no roles', ['user_id' => $user->id]);
@@ -180,7 +180,7 @@ class AuthSessionService
];
}
$this->writeCiAuthenticatedSession($user, $roleNames);
$this->writeAuthenticatedSession($user, $roleNames);
if (count($roleNames) === 1) {
session()->put('role', $roleNames[0]);