diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 0ee2adda86..38eea09ff8 100755 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -333,6 +333,27 @@ public function sendForReOtp($mobile, $code) } public function requestOtp(Request $request) + { + $this->validate($request, [ + 'code' => 'required|numeric', + 'mobile' => 'required|numeric', + ]); + try { + $code = $request->input('code'); + $mobile = $request->input('mobile'); + $number = $code.$mobile; + $result = $this->sendOtp($mobile, $code); + $response = ['type' => 'success', 'message' => 'OTP has been sent to '.$number]; + + return response()->json($response); + } catch (\Exception $ex) { + $result = [$ex->getMessage()]; + + return response()->json(compact('result'), 500); + } + } + + public function requestOtpFromAjax(Request $request) { $this->validate($request, [ 'email' => 'required|email', diff --git a/app/Http/routes.php b/app/Http/routes.php index 4bb117998d..3209f9bfe1 100755 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -367,9 +367,11 @@ }); Route::get('otp/send', 'Auth\AuthController@requestOtp'); +Route::get('otp/sendByAjax', 'Auth\AuthController@requestOtpFromAjax'); Route::get('otp/verify', 'Auth\AuthController@postOtp'); Route::get('email/verify', 'Auth\AuthController@verifyEmail'); Route::get('resend_otp', 'Auth\AuthController@retryOTP'); + Route::get('verify', function () { $user = \Session::get('user'); if ($user) { diff --git a/resources/views/themes/default1/front/auth/login-register.blade.php b/resources/views/themes/default1/front/auth/login-register.blade.php index de22ce3e63..65edb850ac 100644 --- a/resources/views/themes/default1/front/auth/login-register.blade.php +++ b/resources/views/themes/default1/front/auth/login-register.blade.php @@ -654,7 +654,7 @@ function sendOTP() { 'password': $('#email_password').val() }; $.ajax({ - url: '{{url('otp/send')}}', + url: '{{url('otp/sendByAjax')}}', type: 'GET', data: data, success: function (response) {