diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 495a0dd..01c8545 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -233,19 +233,19 @@ public function register(Request $request) // ✅ Check if email can receive a message before creating the user if (isset($data['email'])) { $code = rand(1000, 9999); - try { - if ($method === 'code') { - \Mail::to($data['email'])->send(new \App\Mail\VerifyEmailCodeMail($code)); - } else { - $verificationUrl = url("api/auth/verify-email-link/{$token}?package={$packageNameValue}"); - \Mail::to($data['email'])->send(new \App\Mail\VerifyEmailLinkMail($verificationUrl)); - } - } catch (\Exception $e) { - return response()->json([ - 'error' => $e->getMessage(), - 'message' => 'لطفا آدرس ایمیل خود را بررسی کنید و مجدد تلاش کنید' - ], 400); - } + // try { + // if ($method === 'code') { + // \Mail::to($data['email'])->send(new \App\Mail\VerifyEmailCodeMail($code)); + // } else { + // $verificationUrl = url("api/auth/verify-email-link/{$token}?package={$packageNameValue}"); + // \Mail::to($data['email'])->send(new \App\Mail\VerifyEmailLinkMail($verificationUrl)); + // } + // } catch (\Exception $e) { + // return response()->json([ + // 'error' => $e->getMessage(), + // 'message' => 'لطفا آدرس ایمیل خود را بررسی کنید و مجدد تلاش کنید' + // ], 400); + // } // try { // // Try sending email // \Mail::to($data['email'])->send(new \App\Mail\VerifyEmailCodeMail($code)); @@ -453,59 +453,7 @@ public function checkOTP(Request $request) 'token' => $token, ]); } -public function requestMobileVerification(Request $request) -{ - $data = $request->validate([ - 'mobile' => ['required', 'string', new MobileNumber], - ]); - $mobile = MobileNumberHelper::formatMobile($data['mobile']); - - if (User::where('mobile', $mobile)->where('id', '!=', auth()->id())->exists()) { - return response()->json(['message' => 'mobile already taken'], 400); - } - - $otp = rand(10000, 99999); - - auth()->user()->otpTokens()->create([ - 'token' => $otp - ]); - - SendOTPJob::dispatch($mobile, (string)$otp); - - return response()->json(['message' => 'otp sent']); -} - -public function confirmMobileVerification(Request $request) -{ - $data = $request->validate([ - 'mobile' => ['required', 'string', new MobileNumber], - 'token' => 'required|string' - ]); - - $mobile = MobileNumberHelper::formatMobile($data['mobile']); - $user = auth()->user(); - - $otp = $user->otpTokens() - ->where('token', $data['token']) - ->where('created_at', '>', now()->subMinutes(15)) - ->first(); - - if (!$otp) { - return response()->json(['message' => 'invalid token'], 400); - } - - $otp->delete(); - - $user->update([ - 'mobile' => $mobile, - 'mobile_verified_at' => now(), - ]); - - return response()->json([ - 'message' => 'mobile verified successfully' - ]); -} public function updateProfile(Request $request) { $data = $request->validate([