registration api updated
This commit is contained in:
@@ -466,14 +466,28 @@ class AuthController extends Controller
|
||||
if ($validationMessage) {
|
||||
return response()->json(['status' => 400, 'message' => $validationMessage], 400);
|
||||
}
|
||||
if(strlen($request->otp) < 4)
|
||||
{
|
||||
if (strlen($request->otp) < 4) {
|
||||
return response()->json(['status' => 401, 'message' => 'Please enter 4 digit OTP']);
|
||||
}
|
||||
$otp = (int) $request->otp;
|
||||
if (Session::has('user-registration')) {
|
||||
// $user = Session::get('user-registration');
|
||||
if (Session::get('user-registration')['otp'] == $otp) {
|
||||
|
||||
$mobile_otp = $this->otpGenerate(Session::get('user-registration')['contact_number']);
|
||||
$this->thirdPartyOTP(Session::get('user-registration')['contact_number'], $mobile_otp);
|
||||
$userRegistration = Session::get('user-registration');
|
||||
|
||||
// Add the new value to the session data
|
||||
$userRegistration['mobile_otp'] = $mobile_otp;
|
||||
|
||||
// Put the updated session data back into the session
|
||||
Session::put('user-registration', $userRegistration);
|
||||
|
||||
// $userCreated = Session::put('user-registration'['mobile_otp'], $mobile_otp);
|
||||
//here i have to send mobile OTP in this session
|
||||
//updated by hritik on 17-04-2024
|
||||
|
||||
return response()->json(['status' => 200, 'message' => 'OTP verified']);
|
||||
}
|
||||
return response()->json(['status' => 401, 'message' => 'Invalid OTP!']);
|
||||
@@ -566,7 +580,7 @@ class AuthController extends Controller
|
||||
|
||||
Session::forget('user-registration');
|
||||
$otp = $this->otpGenerate($request->email);
|
||||
$mobile_otp = $this->otpGenerate($request->contact_number);
|
||||
// $mobile_otp = $this->otpGenerate($request->contact_number);
|
||||
$userRegistration = [
|
||||
'name' => $request->name,
|
||||
'user_type' => 'Investor',
|
||||
@@ -575,7 +589,7 @@ class AuthController extends Controller
|
||||
'password' => bcrypt($request->password),
|
||||
'contact_number' => $request->contact_number,
|
||||
'otp' => $otp,
|
||||
'mobile_otp' => $mobile_otp,
|
||||
// 'mobile_otp' => $mobile_otp,
|
||||
];
|
||||
$userCreated = Session::put('user-registration', $userRegistration);
|
||||
$mailData = [
|
||||
@@ -583,7 +597,7 @@ 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;
|
||||
@@ -646,7 +660,7 @@ class AuthController extends Controller
|
||||
} else {
|
||||
Session::forget('user-registration');
|
||||
$otp = $this->otpGenerate($request->email);
|
||||
$mobile_otp = $this->otpGenerate($validated['contact_number2']);
|
||||
// $mobile_otp = $this->otpGenerate($validated['contact_number2']);
|
||||
$userRegistration = [
|
||||
'name' => $validated['name2'],
|
||||
'user_type' => 'Asset Manager',
|
||||
@@ -655,7 +669,7 @@ class AuthController extends Controller
|
||||
'contact_number' => $validated['contact_number2'],
|
||||
'password' => bcrypt($validated['password2']),
|
||||
'otp' => $otp,
|
||||
'mobile_otp' => $mobile_otp,
|
||||
// 'mobile_otp' => $mobile_otp,
|
||||
];
|
||||
$userCreated = Session::put('user-registration', $userRegistration);
|
||||
$mailData = [
|
||||
@@ -663,8 +677,11 @@ 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));
|
||||
return response()->json(['status' => 200, 'message' => 'OTP has been sent to your email']);
|
||||
}
|
||||
// $name = $request->name;
|
||||
// $email = $request->email;
|
||||
@@ -756,56 +773,56 @@ class AuthController extends Controller
|
||||
try {
|
||||
$isOtpVerificationFor = $request->isOtpVerificationFor;
|
||||
// $validated = $request->validated();
|
||||
if ($isOtpVerificationFor == 1) {
|
||||
if ($isOtpVerificationFor == 1) {
|
||||
|
||||
$emailOtp = $request->email_otp;
|
||||
$emailOtp = $request->email_otp;
|
||||
|
||||
$emailToAdd = $request->email2;
|
||||
$emailToAdd = $request->email2;
|
||||
|
||||
$userEmailOtpData = UserOtp::where('email', $emailToAdd)->where('otp', $emailOtp)->first(); // checking user email otp data
|
||||
$userEmailOtpData = UserOtp::where('email', $emailToAdd)->where('otp', $emailOtp)->first(); // checking user email otp data
|
||||
// dd($userEmailOtpData);
|
||||
if (!$userEmailOtpData) {
|
||||
return response()->json(['status' => 400, 'message' => 'Email OTP Did Not Matched!'], 400);
|
||||
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);
|
||||
}
|
||||
if ($userEmailOtpData) {
|
||||
return response()->json(['status' => 200, 'message' => 'Email OTP verified Successfully']);
|
||||
}
|
||||
}
|
||||
if (now() > $userEmailOtpData->expire_at) {
|
||||
return response()->json(['status' => 400, 'message' => 'OTP has been expired!'], 400);
|
||||
}
|
||||
if ($userEmailOtpData) {
|
||||
return response()->json(['status' => 200, 'message' => 'Email OTP verified Successfully']);
|
||||
}
|
||||
}
|
||||
if ($isOtpVerificationFor == 2) {
|
||||
$contactOtp = $request->contact_otp;
|
||||
$contactToAdd = $request->contact_number2;
|
||||
if ($isOtpVerificationFor == 2) {
|
||||
$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);
|
||||
}
|
||||
$userContactOtpData = UserOtp::where('contact_number', $contactToAdd)->where('contact_otp', $contactOtp)->first();
|
||||
|
||||
$userCreated = User::create([
|
||||
'name' => $request->name2,
|
||||
'user_type' => 'Asset Manager',
|
||||
'authorized_representative_name' => $request->authorized_representative_name,
|
||||
'email' => $request->email2,
|
||||
'contact_number' => $request->contact_number2,
|
||||
'password' => bcrypt($request->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]);
|
||||
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->name2,
|
||||
'user_type' => 'Asset Manager',
|
||||
'authorized_representative_name' => $request->authorized_representative_name,
|
||||
'email' => $request->email2,
|
||||
'contact_number' => $request->contact_number2,
|
||||
'password' => bcrypt($request->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!'.$e->getMessage()], 400);
|
||||
return response()->json(['status' => 400, 'message' => 'Error While Registation Details!' . $e->getMessage()], 400);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -834,10 +851,10 @@ class AuthController extends Controller
|
||||
$validator = Validator::make($request->all(), [
|
||||
'user' => 'required',
|
||||
'password' => [
|
||||
'required',
|
||||
// 'min:8',
|
||||
// 'regex:/^.*(?=.{3,})(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[\d\x])(?=.*[!$#%@]).*$/'
|
||||
],
|
||||
'required',
|
||||
// 'min:8',
|
||||
// 'regex:/^.*(?=.{3,})(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[\d\x])(?=.*[!$#%@]).*$/'
|
||||
],
|
||||
]);
|
||||
|
||||
// if ($validator->fails()) {
|
||||
@@ -918,8 +935,7 @@ class AuthController extends Controller
|
||||
if ($validationMessage) {
|
||||
return response()->json(['status' => 400, 'message' => $validationMessage], 400);
|
||||
}
|
||||
if(strlen($request->otp) < 4)
|
||||
{
|
||||
if (strlen($request->otp) < 4) {
|
||||
return response()->json(['status' => 401, 'message' => 'Please enter 4 digit OTP']);
|
||||
}
|
||||
$otp = (int) $request->otp;
|
||||
|
||||
Reference in New Issue
Block a user