good so far
This commit is contained in:
@@ -20,7 +20,7 @@ class VerificationController extends Controller
|
||||
$request->validate([
|
||||
'phone' => ['required', 'regex:/^\+993 [67]\d \d{2} \d{2} \d{2}$/']
|
||||
], [
|
||||
'phone.regex' => 'The phone number must be in the format: +993 KX XX XX XX (where K is 6 or 7).'
|
||||
'phone.regex' => 'Telefon belgiňiz şu formatda bolmaly: +993 KX XX XX XX (bu ýerde K 6 ýa-da 7).'
|
||||
]);
|
||||
|
||||
$phone = unmask_phone($request->phone);
|
||||
@@ -28,9 +28,6 @@ class VerificationController extends Controller
|
||||
// Generate a 4-digit OTP
|
||||
$otp = (string) rand(1000, 9999);
|
||||
|
||||
// Log it to simulate SMS
|
||||
Log::info('Tassyklaýyş belgi: ' . $otp);
|
||||
|
||||
// Store in DB
|
||||
PhoneVerification::updateOrCreate(
|
||||
['phone' => $phone],
|
||||
@@ -60,6 +57,32 @@ class VerificationController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function resendOtp()
|
||||
{
|
||||
$phone = session()->get('verify_phone');
|
||||
|
||||
if (!$phone) {
|
||||
return redirect()->route('verification.index');
|
||||
}
|
||||
|
||||
// Generate a 4-digit OTP
|
||||
$otp = (string) rand(1000, 9999);
|
||||
|
||||
// Store in DB
|
||||
PhoneVerification::updateOrCreate(
|
||||
['phone' => $phone],
|
||||
[
|
||||
'otp' => $otp,
|
||||
'expires_at' => now()->addMinutes(10),
|
||||
'verified' => false
|
||||
]
|
||||
);
|
||||
|
||||
sendSMS($phone, $otp);
|
||||
|
||||
return back()->with('status', 'Täze kod iberildi!');
|
||||
}
|
||||
|
||||
public function verifyOtp(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
@@ -70,11 +93,11 @@ class VerificationController extends Controller
|
||||
$verification = PhoneVerification::query()->where('phone', $request->phone)->first();
|
||||
|
||||
if (!$verification || $verification->otp !== $request->otp) {
|
||||
return back()->withErrors(['otp' => 'Invalid OTP.']);
|
||||
return back()->withErrors(['otp' => 'Nädogry kod.']);
|
||||
}
|
||||
|
||||
if ($verification->expires_at < now()) {
|
||||
return back()->withErrors(['otp' => 'OTP has expired.']);
|
||||
return back()->withErrors(['otp' => 'Kodyň möhleti gutardy.']);
|
||||
}
|
||||
|
||||
// Mark as verified
|
||||
|
||||
@@ -19,6 +19,6 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
app()->setLocale('tk');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user