From 468e936310ec6d504096ef47ac22ee5d3ed3f274 Mon Sep 17 00:00:00 2001
From: Ritikesh yadav
Date: Fri, 19 Apr 2024 15:16:12 +0530
Subject: [PATCH] added resend otp while creating account and solving freedcamp
issue
---
app/Http/Controllers/AuthController.php | 102 +++++++++++++++---
.../AlternativeInvestmentFundController.php | 2 +-
.../Frontend/DashboardController.php | 21 ++--
app/Models/RegistrationOtp.php | 14 +++
..._111556_create_registration_otps_table.php | 37 +++++++
.../js/FrontendJs/register/verify_otp.js | 7 +-
.../Pages/profile/dashboard.blade.php | 25 ++---
.../views/Frontend/Pages/register.blade.php | 2 +-
.../Pages/register_mobile_otp.blade.php | 76 ++++++++++++-
.../Frontend/Pages/register_otp.blade.php | 74 ++++++++++++-
.../components/angel-fund-product.blade.php | 3 +-
routes/api.php | 2 +
12 files changed, 318 insertions(+), 47 deletions(-)
create mode 100644 app/Models/RegistrationOtp.php
create mode 100644 database/migrations/2024_04_19_111556_create_registration_otps_table.php
diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php
index d14bb47..7e91b79 100644
--- a/app/Http/Controllers/AuthController.php
+++ b/app/Http/Controllers/AuthController.php
@@ -18,7 +18,7 @@ use Laravel\Sanctum\PersonalAccessToken;
use App\Services\AuthService;
use Carbon\Carbon;
use App\Http\Requests\StoreAssetManagerRegistrationRequest;
-
+use App\Models\RegistrationOtp;
class AuthController extends Controller
{
@@ -450,6 +450,50 @@ class AuthController extends Controller
}
}
+ public function resendOtpForMobile()
+ {
+ // dd(Session::get('user-registration'));
+ if(!Session::has('user-registration')) {
+ return response()->json(['status' => 401, 'message' => 'Something error!, Please fill the form again']);
+ }
+ else{
+ $mailData = [
+ 'title' => 'Mail from ItSolutionStuff.com',
+ 'body' => 'This is for testing email using smtp.'
+ ];
+ $otp = rand(1000,9999);
+ // Mail::to(Session::get('user-registration')['email'])->send(new OtpMail($mailData, $otp));
+ $this->thirdPartyOTP(Session::get('user-registration')['contact_number'], $otp);
+ $oldSession = Session::get('user-registration');
+ $oldSession['mobile_otp'] = $otp;
+ Session::put('user-registration',$oldSession);
+
+ RegistrationOtp::where('contact_number',Session::get('user-registration')['contact_number'])->update(['contact_otp'=>$otp,'contact_expire_at'=>Carbon::now()->addMinutes('2')]);
+ return response()->json(['status' => 200, 'message' => 'OTP has been resend to your mobile number']);
+ }
+ }
+
+ public function resendOtpForEmail()
+ {
+ if(!Session::has('user-registration')) {
+ return response()->json(['status' => 401, 'message' => 'Something error!, Please fill the form again']);
+ }
+ else{
+ $mailData = [
+ 'title' => 'Mail from ItSolutionStuff.com',
+ 'body' => 'This is for testing email using smtp.'
+ ];
+ $otp = rand(1000,9999);
+ Mail::to(Session::get('user-registration')['email'])->send(new OtpMail($mailData, $otp));
+ $oldSession = Session::get('user-registration');
+ $oldSession['otp'] = $otp;
+ Session::put('user-registration',$oldSession);
+
+ RegistrationOtp::where('email',Session::get('user-registration')['email'])->update(['email_otp'=>$otp,'email_expire_at'=>Carbon::now()->addMinutes('2')]);
+ return response()->json(['status' => 200, 'message' => 'OTP has been resend to your email']);
+ }
+ }
+
public function enteredEmailOTP(Request $request)
{
// dd((int)$request->otp, Session::get('user-registration')['otp']);
@@ -463,8 +507,9 @@ class AuthController extends Controller
'max' => 'The :attribute field must be 4 digits',
]);
$validationMessage = $this->validationError($validator);
+ // dd($validationMessage);
if ($validationMessage) {
- return response()->json(['status' => 400, 'message' => $validationMessage], 400);
+ return response()->json(['status' => 401, 'message' => $validationMessage]);
}
if (strlen($request->otp) < 4) {
return response()->json(['status' => 401, 'message' => 'Please enter 4 digit OTP']);
@@ -472,7 +517,17 @@ class AuthController extends Controller
$otp = (int) $request->otp;
if (Session::has('user-registration')) {
// $user = Session::get('user-registration');
- if (Session::get('user-registration')['otp'] == $otp) {
+ $registrationOtpData = RegistrationOtp::where('email', Session::get('user-registration')['email'])->first();
+
+
+ if (now() > $registrationOtpData->email_expire_at) {
+ //email otp has expired
+ return response()->json(['status' => 401, 'message' => 'Your Email OTP has been Expired']);
+ }
+
+
+ if ($registrationOtpData->email_otp == $otp) {
+ // 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);
@@ -484,6 +539,15 @@ class AuthController extends Controller
// Put the updated session data back into the session
Session::put('user-registration', $userRegistration);
+
+ //here we have to update the entry of Registration_otps
+
+ RegistrationOtp::where('email',Session::get('user-registration')['email'])->update([
+ 'contact_number'=>(int)Session::get('user-registration')['contact_number'],
+ 'contact_otp'=>$mobile_otp,
+ 'contact_expire_at'=>Carbon::now()->addMinutes('2'),
+ ]);
+
// $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
@@ -562,7 +626,7 @@ class AuthController extends Controller
$insertOtp = UserOtp::create([
'contact_number' => $request->contact_number,
- 'email' => $request->email,//emai
+ 'email' => $request->email, //emai
'expire_at' => Carbon::now()->addMinutes('5'),
'otp' => $otp, //email otp
'contact_otp' => $mobile_otp //contact OTP
@@ -596,6 +660,7 @@ class AuthController extends Controller
'title' => 'Mail from ItSolutionStuff.com',
'body' => 'This is for testing email using smtp.'
];
+ RegistrationOtp::updateOrCreate(['email' => $request->email],['email' => $request->email, 'email_otp' => $otp, 'email_expire_at' => Carbon::now()->addMinutes('2')]);
Mail::to($request->email)->send(new OtpMail($mailData, $otp));
// $this->thirdPartyOTP($request->contact_number, $mobile_otp);
@@ -650,7 +715,7 @@ class AuthController extends Controller
$this->thirdPartyOTP($request->contact_number2, $mobile_otp);
$insertOtp = UserOtp::create([
'contact_number' => $request->contact_number2,
- 'email' => $request->email2,//emai
+ 'email' => $request->email2, //emai
'expire_at' => Carbon::now()->addMinutes('5'),
'otp' => $otp, //email otp
'contact_otp' => $mobile_otp //contact OTP
@@ -678,7 +743,7 @@ class AuthController extends Controller
];
Mail::to($validated['email2'])->send(new OtpMail($mailData, $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']);
@@ -756,8 +821,6 @@ class AuthController extends Controller
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);
}
@@ -780,7 +843,7 @@ class AuthController extends Controller
$emailToAdd = $request->email2;
$userEmailOtpData = UserOtp::where('email', $emailToAdd)->where('otp', $emailOtp)->first(); // checking user email otp data
-// dd($userEmailOtpData);
+ // dd($userEmailOtpData);
if (!$userEmailOtpData) {
return response()->json(['status' => 400, 'message' => 'Email OTP Did Not Matched!'], 400);
}
@@ -820,7 +883,6 @@ class AuthController extends Controller
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);
}
@@ -851,10 +913,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()) {
@@ -875,8 +937,7 @@ 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);
@@ -933,7 +994,7 @@ class AuthController extends Controller
]);
$validationMessage = $this->validationError($validator);
if ($validationMessage) {
- return response()->json(['status' => 400, 'message' => $validationMessage], 400);
+ return response()->json(['status' => 401, 'message' => $validationMessage]);
}
if (strlen($request->otp) < 4) {
return response()->json(['status' => 401, 'message' => 'Please enter 4 digit OTP']);
@@ -941,6 +1002,13 @@ class AuthController extends Controller
$otp = (int) $request->otp;
if (Session::has('user-registration')) {
$userDetails = Session::get('user-registration');
+ $registrationOtp = RegistrationOtp::where('contact_number',$userDetails['contact_number'])->first();
+ // dd($userDetails);
+ if(now() > $registrationOtp->contact_expire_at)
+ {
+ return response()->json(['status' => 401, 'message' => 'Mobile OTP has been expired!']);
+ // return
+ }
if ($userDetails['mobile_otp'] !== $otp) {
return response()->json(['status' => 400, 'message' => 'OTP Did Not Matched!']);
}
diff --git a/app/Http/Controllers/Frontend/AlternativeInvestmentFundController.php b/app/Http/Controllers/Frontend/AlternativeInvestmentFundController.php
index 91135a8..7126233 100644
--- a/app/Http/Controllers/Frontend/AlternativeInvestmentFundController.php
+++ b/app/Http/Controllers/Frontend/AlternativeInvestmentFundController.php
@@ -83,7 +83,7 @@ class AlternativeInvestmentFundController extends Controller
// dd($this->aif->openAF()->getData());
return view('Frontend.Pages.alternative-investment-fund.angel-fund', [
'openAF' => $this->aif->openAF()->getData(),
- 'fullyFundedAF' => $this->aif->fullyFundedAF()->getData(),
+ // 'fullyFundedAF' => $this->aif->fullyFundedAF()->getData(),
'resaleAF' => $this->aif->resaleAF()->getData(),
'learnMore' => $this->aif->angelFundLearnMore()->getData()
]);
diff --git a/app/Http/Controllers/Frontend/DashboardController.php b/app/Http/Controllers/Frontend/DashboardController.php
index 5ff0ba4..6723db6 100644
--- a/app/Http/Controllers/Frontend/DashboardController.php
+++ b/app/Http/Controllers/Frontend/DashboardController.php
@@ -34,15 +34,19 @@ class DashboardController extends Controller
$user = $this->getUser()->data;
$currentInvestmentProduct = $this->view_investors_details('Holding');
$reedemedInvestmentProduct = $this->view_investors_details('Reedemed');
+ // watchlist
$aifInvestmentWatchlist = $this->aifInvestmentWatchlist()['data'];
$freInvestmentWatchlist = $this->freInvestmentWatchlist()['data'];
$opInvestmentWatchlist = $this->opInvestmentWatchlist()['data'];
+ // sold
$aifSoldInvestmentWatchlist = $this->aifSoldInvestmentWatchlist()['data'];
$freSoldInvestmentWatchlist = $this->freSoldInvestmentWatchlist()['data'];
$opSoldInvestmentWatchlist = $this->opSoldInvestmentWatchlist()['data'];
+ // bought
$aifInvestmentListed = $this->aifInvestmentListed()['data'];
$freInvestmentListed = $this->freInvestmentListed()['data'];
$opInvestmentListed = $this->opInvestmentListed()['data'];
+ //
$marketPlaceAIFSellerData = $this->getMarketplaceAIFSellerData();
$marketPlaceFRESellerData = $this->getMarketplaceFRESellerData();
$marketPlaceOPSellerData = $this->getMarketplaceOPSellerData();
@@ -766,8 +770,10 @@ class DashboardController extends Controller
->alernativeInvestmentFund()
->sold()
->where('listing_status', '!=', 'Hide')
+ // ->where('marketplace_aif_sellers.listing_status', 'Hide')
->select('name_of_the_aif_fund', 'fund_category', 'fund_strategy', 'type_of_fund', 'total_capital_commitment', 'uncalled_capital_commitment')
->get();
+ // dd($data);
return $data;
}
@@ -778,6 +784,7 @@ class DashboardController extends Controller
->fractionalRealEstate()
->sold()
->where('listing_status', '!=', 'Hide')
+ // ->where('marketplace_fre_sellers.listing_status', 'Hide')
->select('property_name', 'property_address', 'property_grade', 'asset_type', 'fractional_real_estate_platform', 'expected_selling_price')
->get();
return $data;
@@ -800,16 +807,18 @@ class DashboardController extends Controller
$data['data'] = MarketplaceSellerForm::query()
->where('marketplace_seller_forms.users_id', auth()->guard('users')->user()->id)
->join('marketplace_aif_sellers', 'marketplace_seller_forms.id', 'marketplace_aif_sellers.seller_forms_id')
+ ->where('marketplace_aif_sellers.listing_status', '!=', 'Hide')
->select('name_of_the_aif_fund', 'fund_category', 'fund_strategy', 'type_of_fund', 'total_capital_commitment', 'uncalled_capital_commitment')
->get();
- return $data;
- }
-
- public function freInvestmentListed()
- {
- $data['data'] = MarketplaceSellerForm::query()
+ return $data;
+ }
+
+ public function freInvestmentListed()
+ {
+ $data['data'] = MarketplaceSellerForm::query()
->where('marketplace_seller_forms.users_id', auth()->guard('users')->user()->id)
->join('marketplace_fre_sellers', 'marketplace_seller_forms.id', 'marketplace_fre_sellers.seller_forms_id')
+ ->where('marketplace_fre_sellers.listing_status', '!=', 'Hide')
->select('property_name', 'property_address', 'property_grade', 'asset_type', 'fractional_real_estate_platform', 'expected_selling_price')
->get();
return $data;
diff --git a/app/Models/RegistrationOtp.php b/app/Models/RegistrationOtp.php
new file mode 100644
index 0000000..6e23c8f
--- /dev/null
+++ b/app/Models/RegistrationOtp.php
@@ -0,0 +1,14 @@
+id();
+ $table->integer('contact_number');
+ $table->integer('contact_otp');
+ $table->dateTime('contact_expire_at');
+ $table->string('email');
+ $table->integer('email_otp');
+ $table->dateTime('email_expire_at');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('registration_otps');
+ }
+}
diff --git a/public/assets/js/FrontendJs/register/verify_otp.js b/public/assets/js/FrontendJs/register/verify_otp.js
index 35e5f03..67984e5 100644
--- a/public/assets/js/FrontendJs/register/verify_otp.js
+++ b/public/assets/js/FrontendJs/register/verify_otp.js
@@ -54,6 +54,7 @@ $(document).ready(function () {
$("#input_2").val().toString() +
$("#input_3").val().toString() +
$("#input_4").val().toString();
+ // alert(otp)
$.ajaxSetup({
headers: {
@@ -73,8 +74,9 @@ $(document).ready(function () {
// dataType: 'json',
success: function (response) {
+ console.log(response);
if (response.status != 200) {
- // Swal.fire({
+ // Swal.fire({
// text: response.message,
// icon: "error",
@@ -89,7 +91,8 @@ $(document).ready(function () {
// $(".otp").val("");
// }
// });
- toastr.warning(response.message);
+ // alert(response.message);
+ toastr.error(response.message);
} else {
toastr.success(response.message);
setTimeout(function () {
diff --git a/resources/views/Frontend/Pages/profile/dashboard.blade.php b/resources/views/Frontend/Pages/profile/dashboard.blade.php
index 775c6fe..5e21b3e 100644
--- a/resources/views/Frontend/Pages/profile/dashboard.blade.php
+++ b/resources/views/Frontend/Pages/profile/dashboard.blade.php
@@ -367,13 +367,14 @@
@foreach ($aifInvestmentWatchlist as $data)
+ {{-- @dd($data) --}}
| {{ $data->name_of_the_aif_fund }} |
- {{ $data->fund_category }} |
+ {{ $data->getAttributes()['fund_category'] }} |
{{ $data->type_of_fund }} |
{{ $data->fund_strategy }} |
- {{ $data->total_capital_commitment }} |
- {{ $data->uncalled_capital_commitment }} |
+ {{ IND_money_format($data->total_capital_commitment) }} |
+ {{ IND_money_format($data->uncalled_capital_commitment) }} |
@endforeach
@@ -402,7 +403,7 @@
{{ $data->property_grade }} |
{{ $data->asset_type }} |
{{ $data->fractional_real_estate_platform }} |
- {{ $data->expected_selling_price }} |
+ {{ IND_money_format($data->expected_selling_price) }} |
@endforeach
@@ -468,7 +469,7 @@
- @forelse ($marketPlaceAIFSellerData as $item)
+ @foreach ($marketPlaceAIFSellerData as $item)
| {{ $item->marketplace_aif_sellers_data->name_of_the_aif_fund }}
|
@@ -483,9 +484,9 @@
{{ $item->marketplace_aif_sellers_data->uncalled_capital_commitment }}
|
- @empty
- No data found
- @endforelse
+ {{-- @empty
+ No data found
--}}
+ @endforeach
@@ -505,7 +506,7 @@
- @forelse ($marketPlaceFRESellerData as $item)
+ @foreach ($marketPlaceFRESellerData as $item)
| {{ $item->marketplace_fre_sellers_data->property_name }}
|
@@ -520,9 +521,9 @@
{{ $item->marketplace_fre_sellers_data->expected_selling_price }}
|
- @empty
- No data found
- @endforelse
+ {{-- @empty
+ No data found
--}}
+ @endforeach
diff --git a/resources/views/Frontend/Pages/register.blade.php b/resources/views/Frontend/Pages/register.blade.php
index 9cb2814..1983230 100644
--- a/resources/views/Frontend/Pages/register.blade.php
+++ b/resources/views/Frontend/Pages/register.blade.php
@@ -27,7 +27,7 @@
-
+
diff --git a/resources/views/Frontend/Pages/register_mobile_otp.blade.php b/resources/views/Frontend/Pages/register_mobile_otp.blade.php
index 1e8ed02..1eb4bfd 100644
--- a/resources/views/Frontend/Pages/register_mobile_otp.blade.php
+++ b/resources/views/Frontend/Pages/register_mobile_otp.blade.php
@@ -27,10 +27,10 @@
- OTP has been sent to your registered email address.
OTP valid for sec
- Didn't receive any otp? Resend OTP
+ OTP has been sent to your mobile number.
OTP valid for sec
+ Didn't receive any otp? Resend OTP
@@ -55,3 +55,71 @@
@endsection
+@section('scripts')
+
+@endsection
\ No newline at end of file
diff --git a/resources/views/Frontend/Pages/register_otp.blade.php b/resources/views/Frontend/Pages/register_otp.blade.php
index 49545ae..757c38e 100644
--- a/resources/views/Frontend/Pages/register_otp.blade.php
+++ b/resources/views/Frontend/Pages/register_otp.blade.php
@@ -28,9 +28,9 @@
OTP has been sent to your registered email address.
OTP valid for sec
- Didn't receive any otp? Resend OTP
+ id="countdowns-timer-for-email"> sec
+ Didn't receive any otp? Resend OTP
@@ -55,3 +55,71 @@
@endsection
+@section('scripts')
+
+@endsection
\ No newline at end of file
diff --git a/resources/views/components/angel-fund-product.blade.php b/resources/views/components/angel-fund-product.blade.php
index d68155f..9055290 100644
--- a/resources/views/components/angel-fund-product.blade.php
+++ b/resources/views/components/angel-fund-product.blade.php
@@ -2,8 +2,9 @@
{{ $type }}
@if($afAllData->data)
-
+
@foreach($afAllData as $afData)
+ {{-- @dd($afData) --}}
@foreach ($afData as $data)