mohan #5

Merged
mohanmd merged 46 commits from mohan into master 2026-06-15 09:13:23 +00:00
Showing only changes of commit c6063aa980 - Show all commits

View File

@ -115,7 +115,7 @@ public function register(Request $request)
\Illuminate\Support\Facades\Cache::put('employer_otp_' . $request->email, [
'code' => $otp,
'expires_at' => now()->addMinutes(10)
'expires_at' => now()->addMinutes(10)->timestamp
], 600);
// Create inactive User
@ -196,10 +196,25 @@ public function verify(Request $request)
'errors' => $validator->errors()
], 422);
}
$cachedData = \Illuminate\Support\Facades\Cache::get('employer_otp_' . $request->email);
if (!$cachedData || $cachedData['code'] !== $request->otp || now()->gt($cachedData['expires_at'])) {
if (!$cachedData || !isset($cachedData['code']) || !isset($cachedData['expires_at'])) {
return response()->json([
'success' => false,
'message' => 'Invalid or expired verification code.'
], 400);
}
// Handle any dirty/legacy cache objects gracefully
if (is_object($cachedData['expires_at']) || $cachedData['expires_at'] instanceof \__PHP_Incomplete_Class) {
\Illuminate\Support\Facades\Cache::forget('employer_otp_' . $request->email);
return response()->json([
'success' => false,
'message' => 'Session expired. Please request a new verification code.'
], 400);
}
if ($cachedData['code'] !== $request->otp || now()->timestamp > $cachedData['expires_at']) {
return response()->json([
'success' => false,
'message' => 'Invalid or expired verification code.'