two step verification module

This commit is contained in:
Ritikesh yadav
2024-04-03 15:33:08 +05:30
parent 671b17425e
commit 7ac14cff67
8 changed files with 270 additions and 48 deletions

View File

@@ -180,7 +180,7 @@ class ProfileController extends Controller
Mail::to($request->newEmail)->send(new OtpMail($mailData, $otp));
return response()->json([
'status' => 200,
'message' => 'OTP sended on enter email',
'message' => 'OTP has been sent to your email',
]);
}
@@ -193,7 +193,7 @@ class ProfileController extends Controller
'email' => Session::get('newEmail'),
]);
Session::forget(['newEmail', 'otp']);
return response()->json(['status' => 200, 'message' => 'Email update successfully']);
return response()->json(['status' => 200, 'message' => 'Your email updated successfully']);
}
return response()->json(['status' => 201, 'message' => 'OTP invalid !']);
}
@@ -212,13 +212,47 @@ class ProfileController extends Controller
$otp = rand(1000, 9999);
Session::put('contact_number', $request->newcontact_number);
Session::put('mobile_otp', $otp);
$sendOTPMessage = (new sendOTP)->thirdPartyOTP($request->contact_number, $otp);
$this->thirdPartyOTP($request->contact_number, $otp);
return response()->json([
'status' => 200,
'message' => 'OTP sended to contact number',
'message' => 'OTP has been sent to your contact number',
]);
}
public function thirdPartyOTP($number, $otp)
{
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://restapi.smscountry.com/v0.1/Accounts/4F7T5SbGyV7HBrEHxmX4/SMSes/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{
"Text": "Dear Investor, Your login OTP is ' . $otp . '. - Blue Feather Ventures Pvt Ltd.",
"Number": "91' . $number . '",
"SenderId": "BLUFVL",
"DRNotifyUrl": "https://www.domainname.com/notifyurl",
"DRNotifyHttpMethod": "POST",
"Tool": "API"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Basic NEY3VDVTYkd5VjdIQnJFSHhtWDQ6emFXdFEyTlV3ZlZROHB6dGRvVlRZUFdibG01Y1AxRldsbWl2WlVrbg=='
),
));
$response = curl_exec($curl);
curl_close($curl);
return $response;
// return true;
}
public function updateContactNumber(Request $request)
{
// dd(Session::get('mobile_otp'), Session::get('contact_number'), $request->mobile_otp);
@@ -228,7 +262,7 @@ class ProfileController extends Controller
'contact_number' => Session::get('contact_number'),
]);
Session::forget(['contact_number', 'mobile_otp']);
return response()->json(['status' => 200, 'message' => 'Contact number update successfully']);
return response()->json(['status' => 200, 'message' => 'Contact number updated successfully']);
}
return response()->json(['status' => 201, 'message' => 'OTP invalid !']);
}