Skip to content

Commit

Permalink
updates in verify user
Browse files Browse the repository at this point in the history
  • Loading branch information
lohithkumar1707 committed Aug 10, 2017
1 parent 6e9921d commit defc805
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
21 changes: 21 additions & 0 deletions app/Http/Controllers/Auth/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit defc805

Please sign in to comment.