|
|
|
|
@@ -467,7 +467,7 @@ class AuthController extends Controller
|
|
|
|
|
return response()->json(['status' => 400, 'message' => $validationMessage], 400);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$otp = (int)$request->otp;
|
|
|
|
|
$otp = (int) $request->otp;
|
|
|
|
|
if (Session::has('user-registration')) {
|
|
|
|
|
// $user = Session::get('user-registration');
|
|
|
|
|
if (Session::get('user-registration')['otp'] == $otp) {
|
|
|
|
|
@@ -524,21 +524,41 @@ class AuthController extends Controller
|
|
|
|
|
// dd($request->all());
|
|
|
|
|
|
|
|
|
|
if (!$request->has('g-recaptcha-response')) {
|
|
|
|
|
$userCreated = User::create([
|
|
|
|
|
'name' => $request->name,
|
|
|
|
|
'email' => $request->email,
|
|
|
|
|
// $userCreated = User::create([
|
|
|
|
|
// 'name' => $request->name,
|
|
|
|
|
// 'email' => $request->email,
|
|
|
|
|
// 'contact_number' => $request->contact_number,
|
|
|
|
|
// 'password' => bcrypt($request->password),
|
|
|
|
|
// 'user_type' => 'Investor',
|
|
|
|
|
// ]);
|
|
|
|
|
$otp = $this->otpGenerate($request->email);
|
|
|
|
|
$mobile_otp = $this->otpGenerate($request->contact_number);
|
|
|
|
|
$mailData = [
|
|
|
|
|
'title' => 'Mail from ItSolutionStuff.com',
|
|
|
|
|
'body' => 'This is for testing email using smtp.'
|
|
|
|
|
];
|
|
|
|
|
Mail::to($request->email)->send(new OtpMail($mailData, $otp));
|
|
|
|
|
$this->thirdPartyOTP($request->contact_number, $mobile_otp);
|
|
|
|
|
//here we are storing mobile and contact in UserOTp table
|
|
|
|
|
|
|
|
|
|
$insertOtp = UserOtp::create([
|
|
|
|
|
'contact_number' => $request->contact_number,
|
|
|
|
|
'password' => bcrypt($request->password),
|
|
|
|
|
'user_type' => 'Investor',
|
|
|
|
|
'email' => $request->email,//emai
|
|
|
|
|
'expire_at' => Carbon::now()->addMinutes('5'),
|
|
|
|
|
'otp' => $otp, //email otp
|
|
|
|
|
'contact_otp' => $mobile_otp //contact OTP
|
|
|
|
|
]);
|
|
|
|
|
if (!$userCreated) {
|
|
|
|
|
return response()->json(['status' => 400, 'message' => 'Error creating user!'])->setStatusCode(400);
|
|
|
|
|
} else {
|
|
|
|
|
$user = User::where('email', $request->email)->first();
|
|
|
|
|
$userToken = $user->createToken('apiToken')->plainTextToken;
|
|
|
|
|
return response()->json(['status' => 200, 'message' => 'User Created', 'token' => $userToken, 'data' => $user]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return response()->json(['status' => 200, 'message' => 'OTP has been sent to your Email & Contact no.']);
|
|
|
|
|
// if (!$userCreated) {
|
|
|
|
|
// return response()->json(['status' => 400, 'message' => 'Error creating user!'])->setStatusCode(400);
|
|
|
|
|
// } else {
|
|
|
|
|
// $user = User::where('email', $request->email)->first();
|
|
|
|
|
// $userToken = $user->createToken('apiToken')->plainTextToken;
|
|
|
|
|
// return response()->json(['status' => 200, 'message' => 'User Created', 'token' => $userToken, 'data' => $user]);
|
|
|
|
|
// }
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
Session::forget('user-registration');
|
|
|
|
|
$otp = $this->otpGenerate($request->email);
|
|
|
|
|
$mobile_otp = $this->otpGenerate($request->contact_number);
|
|
|
|
|
@@ -558,7 +578,8 @@ class AuthController extends Controller
|
|
|
|
|
'body' => 'This is for testing email using smtp.'
|
|
|
|
|
];
|
|
|
|
|
Mail::to($request->email)->send(new OtpMail($mailData, $otp));
|
|
|
|
|
$this->thirdPartyOTP($request->contact_number,$mobile_otp);
|
|
|
|
|
$this->thirdPartyOTP($request->contact_number, $mobile_otp);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// $name = $request->name;
|
|
|
|
|
// $email = $request->email;
|
|
|
|
|
@@ -582,21 +603,41 @@ class AuthController extends Controller
|
|
|
|
|
{
|
|
|
|
|
$validated = $request->validated();
|
|
|
|
|
if (!$request->has('g-recaptcha-response')) {
|
|
|
|
|
$userCreated = User::create([
|
|
|
|
|
'name' => $validated['name2'],
|
|
|
|
|
'user_type' => 'Asset Manager',
|
|
|
|
|
'authorized_representative_name' => $validated['authorized_representative_name'],
|
|
|
|
|
'email' => $validated['email2'],
|
|
|
|
|
'contact_number' => $validated['contact_number2'],
|
|
|
|
|
'password' => bcrypt($validated['password2']),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $userCreated = User::create([
|
|
|
|
|
// 'name' => $validated['name2'],
|
|
|
|
|
// 'user_type' => 'Asset Manager',
|
|
|
|
|
// 'authorized_representative_name' => $validated['authorized_representative_name'],
|
|
|
|
|
// 'email' => $validated['email2'],
|
|
|
|
|
// 'contact_number' => $validated['contact_number2'],
|
|
|
|
|
// 'password' => bcrypt($validated['password2']),
|
|
|
|
|
// ]);
|
|
|
|
|
// if (!$userCreated) {
|
|
|
|
|
// return response()->json(['status' => 400, 'message' => 'Error creating user!'])->setStatusCode(400);
|
|
|
|
|
// } else {
|
|
|
|
|
// $user = User::where('email', $request->email2)->first();
|
|
|
|
|
// $userToken = $user->createToken('apiToken')->plainTextToken;
|
|
|
|
|
// return response()->json(['status' => 200, 'message' => 'User Created', 'token' => $userToken, 'data' => $user]);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
$otp = $this->otpGenerate($request->email2);
|
|
|
|
|
$mobile_otp = $this->otpGenerate($request->contact_number2);
|
|
|
|
|
$mailData = [
|
|
|
|
|
'title' => 'Mail from ItSolutionStuff.com',
|
|
|
|
|
'body' => 'This is for testing email using smtp.'
|
|
|
|
|
];
|
|
|
|
|
Mail::to($request->email2)->send(new OtpMail($mailData, $otp));
|
|
|
|
|
$this->thirdPartyOTP($request->contact_number2, $mobile_otp);
|
|
|
|
|
$insertOtp = UserOtp::create([
|
|
|
|
|
'contact_number' => $request->contact_number2,
|
|
|
|
|
'email' => $request->email2,//emai
|
|
|
|
|
'expire_at' => Carbon::now()->addMinutes('5'),
|
|
|
|
|
'otp' => $otp, //email otp
|
|
|
|
|
'contact_otp' => $mobile_otp //contact OTP
|
|
|
|
|
]);
|
|
|
|
|
if (!$userCreated) {
|
|
|
|
|
return response()->json(['status' => 400, 'message' => 'Error creating user!'])->setStatusCode(400);
|
|
|
|
|
} else {
|
|
|
|
|
$user = User::where('email', $request->email2)->first();
|
|
|
|
|
$userToken = $user->createToken('apiToken')->plainTextToken;
|
|
|
|
|
return response()->json(['status' => 200, 'message' => 'User Created', 'token' => $userToken, 'data' => $user]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return response()->json(['status' => 200, 'message' => 'OTP has been sent to your Email & Contact no.']);
|
|
|
|
|
} else {
|
|
|
|
|
Session::forget('user-registration');
|
|
|
|
|
$otp = $this->otpGenerate($request->email);
|
|
|
|
|
@@ -617,7 +658,7 @@ class AuthController extends Controller
|
|
|
|
|
'body' => 'This is for testing email using smtp.'
|
|
|
|
|
];
|
|
|
|
|
Mail::to($validated['email2'])->send(new OtpMail($mailData, $otp));
|
|
|
|
|
$this->thirdPartyOTP($validated['contact_number2'],$mobile_otp);
|
|
|
|
|
$this->thirdPartyOTP($validated['contact_number2'], $mobile_otp);
|
|
|
|
|
// Mail::to('yadavritikesh29@gmail.com')->send(new OtpMail($mailData, $otp));
|
|
|
|
|
}
|
|
|
|
|
// $name = $request->name;
|
|
|
|
|
@@ -639,6 +680,110 @@ class AuthController extends Controller
|
|
|
|
|
return response()->json(['status' => 200, 'message' => 'OTP has been sent to your email']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//mobile app email and contact no otp verification for both
|
|
|
|
|
//created on 11-04-2024
|
|
|
|
|
//by hritik
|
|
|
|
|
//use - It will verify the OTPs of investor Registration
|
|
|
|
|
public function verifyContactAndEmailForInvestorApi(Request $request)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$emailOtp = $request->email_otp;
|
|
|
|
|
$emailToAdd = $request->email;
|
|
|
|
|
|
|
|
|
|
$userEmailOtpData = UserOtp::where('email', $emailToAdd)->where('otp', $emailOtp)->first(); // checking user email otp data
|
|
|
|
|
if (!$userEmailOtpData) {
|
|
|
|
|
return response()->json(['status' => 400, 'message' => 'Email OTP Did Not Matched!'], 400);
|
|
|
|
|
}
|
|
|
|
|
if (now() > $userEmailOtpData->expire_at) {
|
|
|
|
|
return response()->json(['status' => 400, 'message' => 'OTP has been expired!'], 400);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$contactOtp = $request->contact_otp;
|
|
|
|
|
$contactToAdd = $request->contact_number;
|
|
|
|
|
|
|
|
|
|
$userContactOtpData = UserOtp::where('contact_number', $contactToAdd)->where('contact_otp', $contactOtp)->first();
|
|
|
|
|
if (!$userContactOtpData) {
|
|
|
|
|
return response()->json(['status' => 400, 'message' => 'Contact OTP Did Not Matched!'], 400);
|
|
|
|
|
}
|
|
|
|
|
if (now() > $userContactOtpData->expire_at) {
|
|
|
|
|
return response()->json(['status' => 400, 'message' => 'OTP has been expired!'], 400);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$userCreated = User::create([
|
|
|
|
|
'name' => $request->name,
|
|
|
|
|
'email' => $request->email,
|
|
|
|
|
'contact_number' => $request->contact_number,
|
|
|
|
|
'password' => bcrypt($request->password),
|
|
|
|
|
'user_type' => 'Investor',
|
|
|
|
|
]);
|
|
|
|
|
if (!$userCreated) {
|
|
|
|
|
return response()->json(['status' => 400, 'message' => 'Error creating user!'])->setStatusCode(400);
|
|
|
|
|
} else {
|
|
|
|
|
$user = User::where('email', $request->email)->first();
|
|
|
|
|
$userToken = $user->createToken('apiToken')->plainTextToken;
|
|
|
|
|
return response()->json(['status' => 200, 'message' => 'User Created', 'token' => $userToken, 'data' => $user]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
return response()->json(['status' => 400, 'message' => 'Error While Registation Details!'], 400);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//mobile app email and contact no otp verification for both
|
|
|
|
|
//created on 11-04-2024
|
|
|
|
|
//by hritik
|
|
|
|
|
//use - It will verify the OTPs of Asset Manager Registration
|
|
|
|
|
|
|
|
|
|
public function verifyContactAndEmailForAssetManagerApi(Request $request)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$validated = $request->validated();
|
|
|
|
|
|
|
|
|
|
$emailOtp = $request->email_otp;
|
|
|
|
|
$emailToAdd = $request->email2;
|
|
|
|
|
|
|
|
|
|
$userEmailOtpData = UserOtp::where('email', $emailToAdd)->where('otp', $emailOtp)->first(); // checking user email otp data
|
|
|
|
|
if (!$userEmailOtpData) {
|
|
|
|
|
return response()->json(['status' => 400, 'message' => 'Email OTP Did Not Matched!'], 400);
|
|
|
|
|
}
|
|
|
|
|
if (now() > $userEmailOtpData->expire_at) {
|
|
|
|
|
return response()->json(['status' => 400, 'message' => 'OTP has been expired!'], 400);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$contactOtp = $request->contact_otp;
|
|
|
|
|
$contactToAdd = $request->contact_number2;
|
|
|
|
|
|
|
|
|
|
$userContactOtpData = UserOtp::where('contact_number', $contactToAdd)->where('contact_otp', $contactOtp)->first();
|
|
|
|
|
if (!$userContactOtpData) {
|
|
|
|
|
return response()->json(['status' => 400, 'message' => 'Contact OTP Did Not Matched!'], 400);
|
|
|
|
|
}
|
|
|
|
|
if (now() > $userContactOtpData->expire_at) {
|
|
|
|
|
return response()->json(['status' => 400, 'message' => 'OTP has been expired!'], 400);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$userCreated = User::create([
|
|
|
|
|
'name' => $validated['name2'],
|
|
|
|
|
'user_type' => 'Asset Manager',
|
|
|
|
|
'authorized_representative_name' => $validated['authorized_representative_name'],
|
|
|
|
|
'email' => $validated['email2'],
|
|
|
|
|
'contact_number' => $validated['contact_number2'],
|
|
|
|
|
'password' => bcrypt($validated['password2']),
|
|
|
|
|
]);
|
|
|
|
|
if (!$userCreated) {
|
|
|
|
|
return response()->json(['status' => 400, 'message' => 'Error creating user!'])->setStatusCode(400);
|
|
|
|
|
} else {
|
|
|
|
|
$user = User::where('email', $request->email2)->first();
|
|
|
|
|
$userToken = $user->createToken('apiToken')->plainTextToken;
|
|
|
|
|
return response()->json(['status' => 200, 'message' => 'User Created', 'token' => $userToken, 'data' => $user]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
return response()->json(['status' => 400, 'message' => 'Error While Registation Details!'], 400);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getUser(Request $request)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
@@ -688,7 +833,8 @@ class AuthController extends Controller
|
|
|
|
|
}
|
|
|
|
|
if (!\Hash::check($password, $user->password)) {
|
|
|
|
|
return response()->json(['status' => 400, 'message' => 'Invalid Credentials!'], 400);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
// $hashedTooken = $request->bearerToken();
|
|
|
|
|
$userToken = $user->createToken('apiToken')->plainTextToken;
|
|
|
|
|
$token = PersonalAccessToken::findToken($userToken);
|
|
|
|
|
@@ -748,7 +894,7 @@ class AuthController extends Controller
|
|
|
|
|
return response()->json(['status' => 400, 'message' => $validationMessage], 400);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$otp = (int)$request->otp;
|
|
|
|
|
$otp = (int) $request->otp;
|
|
|
|
|
if (Session::has('user-registration')) {
|
|
|
|
|
$userDetails = Session::get('user-registration');
|
|
|
|
|
if ($userDetails['mobile_otp'] !== $otp) {
|
|
|
|
|
@@ -966,16 +1112,18 @@ class AuthController extends Controller
|
|
|
|
|
{
|
|
|
|
|
$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 => '{
|
|
|
|
|
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",
|
|
|
|
|
@@ -983,11 +1131,12 @@ class AuthController extends Controller
|
|
|
|
|
"DRNotifyHttpMethod": "POST",
|
|
|
|
|
"Tool": "API"
|
|
|
|
|
}',
|
|
|
|
|
CURLOPT_HTTPHEADER => array(
|
|
|
|
|
'Content-Type: application/json',
|
|
|
|
|
'Authorization: Basic NEY3VDVTYkd5VjdIQnJFSHhtWDQ6emFXdFEyTlV3ZlZROHB6dGRvVlRZUFdibG01Y1AxRldsbWl2WlVrbg=='
|
|
|
|
|
),
|
|
|
|
|
));
|
|
|
|
|
CURLOPT_HTTPHEADER => array(
|
|
|
|
|
'Content-Type: application/json',
|
|
|
|
|
'Authorization: Basic NEY3VDVTYkd5VjdIQnJFSHhtWDQ6emFXdFEyTlV3ZlZROHB6dGRvVlRZUFdibG01Y1AxRldsbWl2WlVrbg=='
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
|
|
|
|
|
|
|