From 57c20431f1cbe6cdf3854886967da3276bf7ffff Mon Sep 17 00:00:00 2001 From: sayliraut Date: Thu, 23 May 2024 16:41:29 +0530 Subject: [PATCH] Admin dashboard login --- .../Controllers/Admin/LoginController.php | 96 +++++++++++- app/Http/Middleware/CheckStatus.php | 26 ++++ app/Mail/AdminPasswordResetEmail.php | 61 ++++++++ app/Models/IamAppAction.php | 22 +++ app/Models/IamAppResource.php | 22 +++ app/Models/IamAppResourceActionLink.php | 23 +++ app/Models/IamPrincipal.php | 131 +++++++++++++++- app/Models/IamPrincipalOtp.php | 33 ++++ app/Models/IamPrincipalRestaurantRole.php | 20 +++ app/Models/IamPrincipalSource.php | 29 ++++ app/Models/IamPrincipalType.php | 30 ++++ app/Models/IamResourceActionLink.php | 23 +++ config/auth.php | 28 ++-- ...12700_create_iam_principal_type_table.php} | 0 ...701_create_iam_principal_source_table.php} | 0 ..._25_112704_create_iam_principal_table.php} | 2 +- ...12800_create_iam_principal_group_table.php | 30 ++++ ...m_principal_principal_group_link_table.php | 33 ++++ ...4_create_iam_principal_biometric_table.php | 33 ++++ ...5_120028_create_iam_app_resource_table.php | 30 ++++ ..._25_120200_create_iam_app_action_table.php | 30 ++++ ...ate_iam_app_resource_action_link_table.php | 33 ++++ ...023_10_25_120600_create_iam_role_table.php | 30 ++++ ...8_create_iam_principal_role_link_table.php | 36 +++++ ..._create_iam_resource_action_link_table.php | 34 +++++ ..._100812_create_iam_principal_otp_table.php | 39 +++++ ...te_iam_principal_restaurant_role_table.php | 35 +++++ ...5_21_135120_create_iam_principal_table.php | 27 ++++ resources/lang/en/auth.php | 105 +++++++++++++ resources/lang/en/success.php | 37 +++++ .../pages/auth/forgot_password.blade.php | 90 +++++++++++ .../views/Admin/pages/auth/otp.blade.php | 91 +++++++++++ .../Admin/pages/auth/password_reset.blade.php | 143 ++++++++++++++++++ .../views/Admin/pages/mail/send_otp.blade.php | 11 ++ routes/web.php | 6 + 35 files changed, 1406 insertions(+), 13 deletions(-) create mode 100644 app/Http/Middleware/CheckStatus.php create mode 100644 app/Mail/AdminPasswordResetEmail.php create mode 100644 app/Models/IamAppAction.php create mode 100644 app/Models/IamAppResource.php create mode 100644 app/Models/IamAppResourceActionLink.php create mode 100644 app/Models/IamPrincipalOtp.php create mode 100644 app/Models/IamPrincipalRestaurantRole.php create mode 100644 app/Models/IamPrincipalSource.php create mode 100644 app/Models/IamPrincipalType.php create mode 100644 app/Models/IamResourceActionLink.php rename database/migrations/{2024_05_22_072745_create_iam_principal_type_table.php => 2023_10_25_112700_create_iam_principal_type_table.php} (100%) rename database/migrations/{2024_05_22_072356_create_iam_principal_source_table.php => 2023_10_25_112701_create_iam_principal_source_table.php} (100%) rename database/migrations/{2024_05_22_070754_create_iam_principal_table.php => 2023_10_25_112704_create_iam_principal_table.php} (97%) create mode 100644 database/migrations/2023_10_25_112800_create_iam_principal_group_table.php create mode 100644 database/migrations/2023_10_25_114852_create_iam_principal_principal_group_link_table.php create mode 100644 database/migrations/2023_10_25_120024_create_iam_principal_biometric_table.php create mode 100644 database/migrations/2023_10_25_120028_create_iam_app_resource_table.php create mode 100644 database/migrations/2023_10_25_120200_create_iam_app_action_table.php create mode 100644 database/migrations/2023_10_25_120221_create_iam_app_resource_action_link_table.php create mode 100644 database/migrations/2023_10_25_120600_create_iam_role_table.php create mode 100644 database/migrations/2023_10_25_120708_create_iam_principal_role_link_table.php create mode 100644 database/migrations/2023_10_25_120710_create_iam_resource_action_link_table.php create mode 100644 database/migrations/2024_01_25_100812_create_iam_principal_otp_table.php create mode 100644 database/migrations/2024_02_12_061945_create_iam_principal_restaurant_role_table.php create mode 100644 database/migrations/2024_05_21_135120_create_iam_principal_table.php create mode 100644 resources/lang/en/auth.php create mode 100644 resources/lang/en/success.php create mode 100644 resources/views/Admin/pages/auth/forgot_password.blade.php create mode 100644 resources/views/Admin/pages/auth/otp.blade.php create mode 100644 resources/views/Admin/pages/auth/password_reset.blade.php create mode 100644 resources/views/Admin/pages/mail/send_otp.blade.php diff --git a/app/Http/Controllers/Admin/LoginController.php b/app/Http/Controllers/Admin/LoginController.php index 4d85ef6..4b43cbb 100644 --- a/app/Http/Controllers/Admin/LoginController.php +++ b/app/Http/Controllers/Admin/LoginController.php @@ -3,10 +3,17 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; +use App\Mail\AdminPasswordResetEmail; use Illuminate\Http\Request; use App\Models\IamPrincipal; +use App\Models\IamPrincipalOtp; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Session; +use Illuminate\Support\Facades\Mail; +use Illuminate\Support\Carbon; class LoginController extends Controller { @@ -28,7 +35,6 @@ class LoginController extends Controller if ($user) { if (Hash::check($validatedData['password'], $user->password)) { - // Log in the user explicitly Auth::guard('admin')->login($user); return jsonResponseWithSuccessMessage(__('success.authentic_success'), 200); } else { @@ -38,4 +44,92 @@ class LoginController extends Controller return jsonResponseWithErrorMessage(__('auth.email'), 401); } } + + public function forgot_password() + { + return view('Admin.pages.auth.forgot_password'); + } + + public function add_forgot_password(Request $request) + { + $user = DB::table('iam_principal')->where('email_address', $request->email)->first(); + if (!$user) { + return jsonResponseWithErrorMessage(__('auth.email'), 404); + } + + $otp = rand(1234, 9999); + $expirationTime = now()->addMinutes(5); + + $data = [ + 'principal_xid' => $user->id, + 'otp_code' => $otp, + 'otp_purpose' => 'admin forgot password', + 'valid_till' => $expirationTime, + 'created_at' => Carbon::now(), + ]; + + $user_token = DB::table('iam_principal_otp')->where('principal_xid', $user->id)->first(); + if ($user_token) { + DB::table('iam_principal_otp') + ->where('principal_xid', $user->id) + ->update($data); + } else { + DB::table('iam_principal_otp') + ->insert($data); + } + + Session::put('admin_data', $data); + + $sessionDetails = Session::get('admin_data'); + + Mail::to($request->email)->send(new AdminPasswordResetEmail($data)); + + return jsonResponseWithSuccessMessage(__('success.authentic_success'), 200); + } + + public function otp_page() + { + return view('Admin.pages.auth.otp'); + } + + public function verify_otp(Request $request) + { + try { + $admin = IamPrincipalOtp::where('principal_xid', $request->id) + ->where('otp_code', $request->otp) + ->where('valid_till', '>', now()) + ->first(); + + if ($admin) { + return jsonResponseWithSuccessMessage(__('success.confirmed_password'), 200); + } else { + return jsonResponseWithErrorMessage(__('auth.otp_expired_invalid'), 401); + } + } catch (\Exception $e) { + Log::error('Passport function failed: ' . $e->getMessage()); + return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500); + return response()->json(['error' => $e->getMessage()]); + } + } + + + public function reset_password_page() + { + return view('Admin.pages.auth.password_reset'); + } + + public function updatePassword(Request $request) + { + $id = $request->reset_id; + $user = IamPrincipal::find($id); + if (!$user) { + return jsonResponseWithErrorMessage(__('auth.user_not_found'), 404); + } + + $user->update([ + 'password' => Hash::make($request->confirm_password), + ]); + + return jsonResponseWithSuccessMessage(__('success.update_data'), 200); + } } diff --git a/app/Http/Middleware/CheckStatus.php b/app/Http/Middleware/CheckStatus.php new file mode 100644 index 0000000..eb2dee0 --- /dev/null +++ b/app/Http/Middleware/CheckStatus.php @@ -0,0 +1,26 @@ +guard('admin')->user(); + if ($admin && $admin->is_active == 1) { + return $next($request); + } else { + return redirect('/')->with('error_msg', 'You must be logged in..'); + } + } +} diff --git a/app/Mail/AdminPasswordResetEmail.php b/app/Mail/AdminPasswordResetEmail.php new file mode 100644 index 0000000..072c7bc --- /dev/null +++ b/app/Mail/AdminPasswordResetEmail.php @@ -0,0 +1,61 @@ +data = $data; + } + + /** + * Get the message envelope. + */ + // public function envelope(): Envelope + // { + // return new Envelope( + // subject: 'Admin Password Reset Email', + // ); + // } + + // /** + // * Get the message content definition. + // */ + // public function content(): Content + // { + // return new Content( + // view: 'admin.pages.mail.send_otp', + // ); + // } + + public function build() + { + $otp = $this->data; + return $this->subject('Mail from Cheers To Seasons') + ->view('Admin.pages.mail.send_otp', ["content" => $otp]); + } + + /** + * Get the attachments for the message. + * + * @return array + */ + public function attachments(): array + { + return []; + } +} diff --git a/app/Models/IamAppAction.php b/app/Models/IamAppAction.php new file mode 100644 index 0000000..8b31043 --- /dev/null +++ b/app/Models/IamAppAction.php @@ -0,0 +1,22 @@ +hasMany(ManageModuleLink::class,'principal_xid', 'id'); + } + + public function feedbacks() + { + return $this->hasMany(ManageFeedback::class, 'principal_xid', 'id'); + } + public function getresturant() + { + return $this->hasMany(IamPrincipalRestaurantRole::class, 'principal_xid', 'id'); + } + + public function getCustomerCount() + { + // Fetch the count of customers + $customerCount = IamPrincipal::where('principal_type_xid', '=', 3)->count(); + + return $customerCount; + } + + + + // protected $fillable = + // [ + // 'principal_type_xid', + // 'principal_source_xid', + // 'user_name', + // 'password_hash', + // 'pin', + // 'first_name', + // 'last_name', + // 'gender', + // 'date_of_birth', + // 'phone_number', + // 'other_phone_number', + // 'email_address', + // 'address_line1', + // 'address_line2', + // 'city_xid', + // 'state_xid', + // 'country_xid', + // 'post_code', + // 'last_login_datetime', + // 'profile_photo', + // 'referral_code', + // 'description', + // 'is_active' + // ]; + + public function getJWTIdentifier() + { + return $this->getKey(); + } + + public function getJWTCustomClaims() + { + return []; + } + + /** + * The attributes that are mass assignable. + * + * @var array + */ + + + /** + * The attributes that should be hidden for serialization. + * + * @var array + */ + protected $hidden = [ + 'password', + 'remember_token', + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + 'email_verified_at' => 'datetime', + 'password' => 'hashed', + ]; + + public function getPermissionGranted($id,$module) + { + // $id is used as authuser id + // $moudle is the slug of sidebar module + + $isSubAdmin = IamPrincipal::where('id',$id)->where('principal_type_xid',2)->first(); + // 'is_admin',1 is for checking the login user is subadmin or not + + $isMainAdmin = IamPrincipal::where('id',$id)->where('principal_type_xid',1)->first(); + if($isMainAdmin){ + return true; + }elseif($isSubAdmin){ + //search for module + $isModule = ManageModule::where('slug',$module)->first(); + if($isModule){ + $isSubAdminModuleLink = ManageModuleLink::where('principal_xid',$id) + ->where('manage_modules_xid',$isModule->id)->first(); + // dd($id,$module,$isSubAdmin->id,$isModule,$isSubAdminModuleLink); + if($isSubAdminModuleLink){ + return true; + }else{ + return false; + } + }else{ + return false; + } + }else{ + return false; + } + } + + public function orders() + { + return $this->hasMany(OrderedPassport::class, 'iam_principal_xid','id'); + } + + public function notification() + { + return $this->hasMany(NotificationDetails::class,'principal_xid', 'id'); + } } diff --git a/app/Models/IamPrincipalOtp.php b/app/Models/IamPrincipalOtp.php new file mode 100644 index 0000000..9dcba3f --- /dev/null +++ b/app/Models/IamPrincipalOtp.php @@ -0,0 +1,33 @@ +belongsTo(IamPrincipal::class, 'principal_xid', 'id')->withDefault(); + } + +} diff --git a/app/Models/IamPrincipalRestaurantRole.php b/app/Models/IamPrincipalRestaurantRole.php new file mode 100644 index 0000000..e15a2e8 --- /dev/null +++ b/app/Models/IamPrincipalRestaurantRole.php @@ -0,0 +1,20 @@ +hasMany(IamPrincipal::class, 'principal_source_xid', 'id'); + } + public function source(){ + return $this->hasOne(IamPrincipal::class,'id','principal_source_xid'); + } +} diff --git a/app/Models/IamPrincipalType.php b/app/Models/IamPrincipalType.php new file mode 100644 index 0000000..0d0b443 --- /dev/null +++ b/app/Models/IamPrincipalType.php @@ -0,0 +1,30 @@ +hasMany(IamPrincipal::class, 'principal_type_xid', 'id'); + } + public function type(){ + return $this->hasOne(IamPrincipal::class,'id','principal_type_xid'); + } +} diff --git a/app/Models/IamResourceActionLink.php b/app/Models/IamResourceActionLink.php new file mode 100644 index 0000000..a938a9c --- /dev/null +++ b/app/Models/IamResourceActionLink.php @@ -0,0 +1,23 @@ + [ - 'guard' => env('AUTH_GUARD', 'web'), - 'passwords' => env('AUTH_PASSWORD_BROKER', 'users'), + 'guard' => 'api', + 'passwords' => 'users', ], /* @@ -38,10 +38,18 @@ return [ 'guards' => [ 'web' => [ 'driver' => 'session', - 'provider' => 'users', + 'provider' => 'iam_principal', + ], + 'api' => [ + 'driver' => 'jwt', + 'provider' => 'iam_principal' + ], + + 'admin' => [ + 'driver' => 'session', + 'provider' => 'admins', ], ], - /* |-------------------------------------------------------------------------- | User Providers @@ -60,15 +68,15 @@ return [ */ 'providers' => [ - 'users' => [ + 'iam_principal' => [ 'driver' => 'eloquent', - 'model' => env('AUTH_MODEL', App\Models\User::class), + 'model' => App\Models\IamPrincipal::class, ], - // 'users' => [ - // 'driver' => 'database', - // 'table' => 'users', - // ], + 'admins' => [ + 'driver' => 'eloquent', + 'model' => App\Models\IamPrincipal::class, + ] ], /* diff --git a/database/migrations/2024_05_22_072745_create_iam_principal_type_table.php b/database/migrations/2023_10_25_112700_create_iam_principal_type_table.php similarity index 100% rename from database/migrations/2024_05_22_072745_create_iam_principal_type_table.php rename to database/migrations/2023_10_25_112700_create_iam_principal_type_table.php diff --git a/database/migrations/2024_05_22_072356_create_iam_principal_source_table.php b/database/migrations/2023_10_25_112701_create_iam_principal_source_table.php similarity index 100% rename from database/migrations/2024_05_22_072356_create_iam_principal_source_table.php rename to database/migrations/2023_10_25_112701_create_iam_principal_source_table.php diff --git a/database/migrations/2024_05_22_070754_create_iam_principal_table.php b/database/migrations/2023_10_25_112704_create_iam_principal_table.php similarity index 97% rename from database/migrations/2024_05_22_070754_create_iam_principal_table.php rename to database/migrations/2023_10_25_112704_create_iam_principal_table.php index ee3f847..ba9e482 100644 --- a/database/migrations/2024_05_22_070754_create_iam_principal_table.php +++ b/database/migrations/2023_10_25_112704_create_iam_principal_table.php @@ -18,7 +18,7 @@ return new class extends Migration $table->unsignedBigInteger('principal_type_xid'); $table->unsignedBigInteger('principal_source_xid'); $table->string('user_name')->nullable(); - $table->string('password_hash')->nullable(); + $table->string('password')->nullable(); $table->string('pin', 4)->nullable(); $table->string('first_name', 255)->nullable(); $table->string('last_name', 255)->nullable(); diff --git a/database/migrations/2023_10_25_112800_create_iam_principal_group_table.php b/database/migrations/2023_10_25_112800_create_iam_principal_group_table.php new file mode 100644 index 0000000..3dfbb98 --- /dev/null +++ b/database/migrations/2023_10_25_112800_create_iam_principal_group_table.php @@ -0,0 +1,30 @@ +id(); + $table->string('principal_group_name',255); + $table->enum('is_active', [1, 0])->default(1)->comment('1=Active, 0=InActive'); + $table->softDeletes(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('iam_principal_group'); + } +}; diff --git a/database/migrations/2023_10_25_114852_create_iam_principal_principal_group_link_table.php b/database/migrations/2023_10_25_114852_create_iam_principal_principal_group_link_table.php new file mode 100644 index 0000000..6c211ea --- /dev/null +++ b/database/migrations/2023_10_25_114852_create_iam_principal_principal_group_link_table.php @@ -0,0 +1,33 @@ +id(); + $table->unsignedBigInteger('principal_xid'); + $table->unsignedBigInteger('principal_group_xid'); + $table->enum('is_active', [1, 0])->default(1)->comment('1=Active, 0=InActive'); + $table->softDeletes(); + $table->timestamps(); + $table->foreign('principal_xid')->references('id')->on('iam_principal')->onDelete('cascade'); + $table->foreign('principal_group_xid')->references('id')->on('iam_principal_group')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('iam_principal_principal_group_link'); + } +}; diff --git a/database/migrations/2023_10_25_120024_create_iam_principal_biometric_table.php b/database/migrations/2023_10_25_120024_create_iam_principal_biometric_table.php new file mode 100644 index 0000000..074afee --- /dev/null +++ b/database/migrations/2023_10_25_120024_create_iam_principal_biometric_table.php @@ -0,0 +1,33 @@ +id(); + $table->unsignedBigInteger('principal_xid'); + $table->string('biometric_type')->nullable(); + $table->string('biometric_data')->nullable(); + $table->enum('is_active', [1, 0])->default(1)->comment('1=Active, 0=InActive'); + $table->softDeletes(); + $table->timestamps(); + $table->foreign('principal_xid')->references('id')->on('iam_principal')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('iam_principal_biometric'); + } +}; diff --git a/database/migrations/2023_10_25_120028_create_iam_app_resource_table.php b/database/migrations/2023_10_25_120028_create_iam_app_resource_table.php new file mode 100644 index 0000000..e0cf3c0 --- /dev/null +++ b/database/migrations/2023_10_25_120028_create_iam_app_resource_table.php @@ -0,0 +1,30 @@ +id(); + $table->string('app_resource_title',255); + $table->enum('is_active', [1, 0])->default(1)->comment('1=Active, 0=InActive'); + $table->softDeletes(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('iam_app_resource'); + } +}; diff --git a/database/migrations/2023_10_25_120200_create_iam_app_action_table.php b/database/migrations/2023_10_25_120200_create_iam_app_action_table.php new file mode 100644 index 0000000..2c14018 --- /dev/null +++ b/database/migrations/2023_10_25_120200_create_iam_app_action_table.php @@ -0,0 +1,30 @@ +id(); + $table->string('action_name',255)->nullable(); + $table->enum('is_active', [1, 0])->default(1)->comment('1=Active, 0=InActive'); + $table->softDeletes(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('iam_app_action'); + } +}; diff --git a/database/migrations/2023_10_25_120221_create_iam_app_resource_action_link_table.php b/database/migrations/2023_10_25_120221_create_iam_app_resource_action_link_table.php new file mode 100644 index 0000000..7936b10 --- /dev/null +++ b/database/migrations/2023_10_25_120221_create_iam_app_resource_action_link_table.php @@ -0,0 +1,33 @@ +id(); + $table->unsignedBigInteger('app_resource_xid'); + $table->unsignedBigInteger('app_action_xid'); + $table->enum('is_active', [1, 0])->default(1)->comment('1=Active, 0=InActive'); + $table->softDeletes(); + $table->timestamps(); + $table->foreign('app_resource_xid')->references('id')->on('iam_app_resource')->onDelete('cascade'); + $table->foreign('app_action_xid')->references('id')->on('iam_app_action')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('iam_app_resource_action_link'); + } +}; diff --git a/database/migrations/2023_10_25_120600_create_iam_role_table.php b/database/migrations/2023_10_25_120600_create_iam_role_table.php new file mode 100644 index 0000000..036a0de --- /dev/null +++ b/database/migrations/2023_10_25_120600_create_iam_role_table.php @@ -0,0 +1,30 @@ +id(); + $table->string('role_name',255)->nullable(); + $table->enum('is_active', [1, 0])->default(1)->comment('1=Active, 0=InActive'); + $table->softDeletes(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('iam_role'); + } +}; diff --git a/database/migrations/2023_10_25_120708_create_iam_principal_role_link_table.php b/database/migrations/2023_10_25_120708_create_iam_principal_role_link_table.php new file mode 100644 index 0000000..0e173f6 --- /dev/null +++ b/database/migrations/2023_10_25_120708_create_iam_principal_role_link_table.php @@ -0,0 +1,36 @@ +id(); + $table->unsignedBigInteger('principal_xid'); + $table->unsignedBigInteger('principal_group_xid'); + $table->unsignedBigInteger('role_xid'); + $table->enum('is_active', [1, 0])->default(1)->comment('1=Active, 0=InActive'); + $table->softDeletes(); + $table->timestamps(); + $table->foreign('principal_xid')->references('id')->on('iam_principal')->onDelete('cascade'); + $table->foreign('principal_group_xid')->references('id')->on('iam_principal_group')->onDelete('cascade'); + $table->foreign('role_xid')->references('id')->on('iam_role')->onDelete('cascade'); + + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('iam_principal_role_link'); + } +}; diff --git a/database/migrations/2023_10_25_120710_create_iam_resource_action_link_table.php b/database/migrations/2023_10_25_120710_create_iam_resource_action_link_table.php new file mode 100644 index 0000000..aedf3cd --- /dev/null +++ b/database/migrations/2023_10_25_120710_create_iam_resource_action_link_table.php @@ -0,0 +1,34 @@ +id(); + $table->unsignedBigInteger('role_xid'); + $table->unsignedBigInteger('app_resource_xid'); + $table->enum('is_active', [1, 0])->default(1)->comment('1=Active, 0=InActive'); + $table->softDeletes(); + $table->timestamps(); + $table->foreign('role_xid')->references('id')->on('iam_role')->onDelete('cascade'); + $table->foreign('app_resource_xid')->references('id')->on('iam_app_resource')->onDelete('cascade'); + + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('iam_resource_action_link'); + } +}; diff --git a/database/migrations/2024_01_25_100812_create_iam_principal_otp_table.php b/database/migrations/2024_01_25_100812_create_iam_principal_otp_table.php new file mode 100644 index 0000000..a555ab6 --- /dev/null +++ b/database/migrations/2024_01_25_100812_create_iam_principal_otp_table.php @@ -0,0 +1,39 @@ +id(); + $table->unsignedBigInteger('principal_xid'); + $table->foreign('principal_xid')->references('id')->on('iam_principal')->onDelete('cascade'); + $table->string('otp_code'); + $table->string('otp_purpose'); + $table->dateTime('valid_till'); + $table->boolean('is_used')->default(0); + $table->smallInteger('active')->default(1); + $table->integer('created_by')->nullable(); + $table->timestamp('created_on')->nullable(); + $table->integer('modified_by')->nullable(); + $table->timestamp('modified_on')->nullable(); + $table->timestamps(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('iam_principal_otp'); + } +}; diff --git a/database/migrations/2024_02_12_061945_create_iam_principal_restaurant_role_table.php b/database/migrations/2024_02_12_061945_create_iam_principal_restaurant_role_table.php new file mode 100644 index 0000000..4b35869 --- /dev/null +++ b/database/migrations/2024_02_12_061945_create_iam_principal_restaurant_role_table.php @@ -0,0 +1,35 @@ +id(); + $table->unsignedBigInteger('principal_xid'); + $table->foreign('principal_xid')->references('id')->on('iam_principal')->onDelete('cascade'); + $table->unsignedBigInteger('restaurant_xid'); + $table->foreign('restaurant_xid')->references('id')->on('manage_vouchers')->onDelete('cascade'); + $table->string('role')->nullable(); + $table->integer('created_by')->nullable(); + $table->integer('modified_by')->nullable(); + $table->softDeletes(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('iam_principal_restaurant_role'); + } +}; diff --git a/database/migrations/2024_05_21_135120_create_iam_principal_table.php b/database/migrations/2024_05_21_135120_create_iam_principal_table.php new file mode 100644 index 0000000..11ce557 --- /dev/null +++ b/database/migrations/2024_05_21_135120_create_iam_principal_table.php @@ -0,0 +1,27 @@ +id(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('iam_principal'); + } +}; diff --git a/resources/lang/en/auth.php b/resources/lang/en/auth.php new file mode 100644 index 0000000..10df0f3 --- /dev/null +++ b/resources/lang/en/auth.php @@ -0,0 +1,105 @@ +'Your account has been logged out successfully.', + 'try_resend_otp'=>'You can resend OTP only after a 2-minutes interval', + 'otp_already_used'=>'OTP has been used already .', + 'failed' => 'These credentials do not match our records.', + 'email' => 'Email not found.', + 'password' => 'The provided password is incorrect.', + 'invalid_current_passsword' => 'Current password is incorrect', + 'sign_in' => 'Sign in Successfully.', + 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', + 'validation_failed' => 'Invalid data entered.', + 'something_went_wrong' => 'Something went wrong.', + 'number_blocked' => 'Your number is blocked for next 24 hours.', + 'otp_sent_successfully' => 'OTP sent successfully.', + 'otp_resend_sent_successfully'=>'OTP resend Successfully', + 'failed_otp' => 'OTP Failed.', + 'otp_expired' => 'OTP expired.', + 'invalid_otp' => 'Invalid OTP.', + 'otp_verified' => 'OTP verified successfully.', + 'failed_to_send_otp' => 'Failed to send OTP. Please try again.', + 'failed_to_verify_otp' => 'Failed to verify OTP. Please try again.', + 'please_login_and_try_again' => 'Please login and try again!', + 'authentication_failed' => 'Authentication failed', + 'reset_password' => 'Reset Password Page.', + 'mobile_number_already_registered' => 'Mobile number already exist. Please try with another number.', + 'verify_mobile_to_reset_password' => 'First verify your mobile number to reset password.', + 'platform_require' => 'Platform is required as a header parameter', + 'invalid_platform' => 'Platform is Invalid', + 'token_expired' => 'Token Expired', + 'version_require' => 'Version is required as a header parameter', + 'invalid_version' => 'Version is Invalid', + 'device_id_require' => 'Device id is required as a header parameter.', + 'invalid_device_id' => 'Device id is Invalid', + 'country_require' => 'Country is required.', + 'incorrect_password' => 'Please enter correct password', + 'incorrect_email' => 'Please enter correct email', + 'user_already_exist' => 'User already exist.', + 'user_not_found' => 'User not found', + 'check_email' => 'Email Id not found', + 'password_updated_successfully' => 'Password Updated Successfully.', + 'gaurdian_does_not_exist' => 'Gaurdian does not exist.', + 'gaurdian_email_already_exist' => 'Gaurdian email already exist.', + 'user_already_logged_in_another_device' => 'You have already logged in another Device. Do you want to proceed ?', + 'username_is_not_available' => 'Username is not available.', + 'email_already_exist' => 'Email already exist.', + 'username_available' => 'Username available.', + 'proceed_to_register' => 'Proceed to register new account.', + 'select_parent_user' => 'Please select above 16 user.', + 'continue_as_guest' => 'Continued as guest.', + 'email_already_linked_with_gaurdian_account' => 'The email is already being used as a guardian account.', + 'would_you_like_to_reactivate_yourt_account' => 'Would you like to reactivate your account?', + 'account_deactivated' => 'Account deactivated.', + 'account_suspended' => 'Account Suspended.', + 'you_have_already_logged_in' => 'You have already logged in on another device.', + 'user_deleted' => 'User has been deleted.', + 'invalid_mobile_number' => 'Invalid mobile number.', + 'account_exist_with_mobile_number' => 'Account already exist with entered mobile number.', + 'account_does_not_exist_for_mobile_number' => "Mobile number doesn't match any existing account. Please check or sign up", + 'account_is_not_active' => 'Account is deactive.', + 'data_fetched_successfully' => 'Data fetch Successfully', + 'data_not_found' => 'Data not found.', + 'data_updated_successfully' => 'Data updated successfully ', + 'passport_not_found' => 'Passport not found', + 'add_to_cart' => 'Passport added to cart successfully', + 'already_taken' => 'You have already taken passport', + 'cart_removed' => 'Cart remove successfully', + 'cart_not_found' => 'Cart not found', + 'quantity_updated' => 'Quantity updated successfully', + 'invalid_data' => 'Invalid data', + 'feedback_store' => 'Feedback store successfully', + 'already_taken_feedback' => 'You already given the feedback', + 'restaurant_data_not_found' => 'Restaurant not found', + 'success_stripe' => 'Stripe Payment done', + 'passport_search' => 'Passport Search successfully', + 'not_found_otp' => 'OTP not found for this user', + 'Rest_user_created' => 'Restaurant user created successfully', + 'User_details_fetch' => 'User details fetch successfully', + 'Voucher_not_found' => 'Voucher not found', + 'delete_user' => 'Customer deleted successfully', + 'rest_delete_user' => 'Restaurant deleted successfully', + 'invalid_code' => 'Invalid order id.', + 'coupon_applied' => 'Coupon applied successfully.', + 'incorrect_email_passport' => 'Incorrect email address and password', + 'form_submitted' => 'Form submitted successfully', + 'capacity_full' => 'capacity is full now', + 'cart_removed_successfully' => 'Cart removed successfully', + 'invalid_redemption_date' => 'The redemption date is not valid', + 'users_imported' => 'Users imported successfully', + 'deleted_user_by_admin' => 'User deleted by admin', + 'otp_expired_invalid' => 'Invalid OTP or expired.' + +]; diff --git a/resources/lang/en/success.php b/resources/lang/en/success.php new file mode 100644 index 0000000..03cb371 --- /dev/null +++ b/resources/lang/en/success.php @@ -0,0 +1,37 @@ +'Payment Intent Created Successfully', + 'data_fetched_successfully' => 'Data Fetched Successfully.', + 'otp_sent_successfully' => 'OTP sent successfully.', + 'data_not_found' => 'Data not found.', + 'password_reset' => 'Password Reset Successfully.', + 'reply_sent' =>'Reply Send Successfully.', + 'delete' => 'Data Deleted Successfully.', + 'update_data' => 'Data Updated Successfully.', + 'save_data' => 'Data Saved Successfully.', + 'data_already_saved' => 'Data has been saved.', + 'change_status' => 'Published.', + 'inactive' =>'Unpublished.', + 'validation' => 'Validation Failed. ', + 'update_status_active' => 'Status Activate successfully.', + 'update_status_inactive' => 'Status Deactivate successfully.', + 'data_deleted' => 'Data Deleted successfully.', + 'date_check' => 'Date must be greater than today date', + 'redeem_voucher' => 'Voucher redeemed successfully.', + 'sent_mail' => 'Mail sent successfully', + 'authentic_success' => 'Authentication successful', + 'confirmed_password' => 'please confirm your passsword', + +]; diff --git a/resources/views/Admin/pages/auth/forgot_password.blade.php b/resources/views/Admin/pages/auth/forgot_password.blade.php new file mode 100644 index 0000000..c2c8968 --- /dev/null +++ b/resources/views/Admin/pages/auth/forgot_password.blade.php @@ -0,0 +1,90 @@ +@extends('admin.layouts.app_login') +@section('title', 'Forgot Password') +@section('content') +
+
+
+ +
+
+ +
+ +@endsection + +@section('scripts') + + + + +@endsection diff --git a/resources/views/Admin/pages/auth/otp.blade.php b/resources/views/Admin/pages/auth/otp.blade.php new file mode 100644 index 0000000..c263f7b --- /dev/null +++ b/resources/views/Admin/pages/auth/otp.blade.php @@ -0,0 +1,91 @@ +@extends('admin.layouts.app_login') +@section('title', 'Cheers To Season - Otp') +@section('content') +
+
+
+ +
+
+ +
+ +@endsection + +@section('scripts') + + + +@endsection diff --git a/resources/views/Admin/pages/auth/password_reset.blade.php b/resources/views/Admin/pages/auth/password_reset.blade.php new file mode 100644 index 0000000..ea91549 --- /dev/null +++ b/resources/views/Admin/pages/auth/password_reset.blade.php @@ -0,0 +1,143 @@ +@extends('admin.layouts.app_login') +@section('title', 'Cheers To Season - Password Reset') +@section('content') +
+
+
+ +
+
+ +
+ +@endsection + +@section('scripts') + + + + + + +@endsection diff --git a/resources/views/Admin/pages/mail/send_otp.blade.php b/resources/views/Admin/pages/mail/send_otp.blade.php new file mode 100644 index 0000000..2972654 --- /dev/null +++ b/resources/views/Admin/pages/mail/send_otp.blade.php @@ -0,0 +1,11 @@ + + + + OTP Email + + +

Your OTP Code

+

Your OTP code is: {{ $content['otp_code'] }}

+

This code will expire in a short period, so please use it promptly.

+ + diff --git a/routes/web.php b/routes/web.php index 6d19c0f..7a37aaa 100644 --- a/routes/web.php +++ b/routes/web.php @@ -22,6 +22,12 @@ use App\Http\Controllers\Admin\LoginController; Route::get('/', [LoginController::class, 'index'])->name('login'); Route::post('/check_login', [LoginController::class, 'login']); +Route::get('/forgot_password', [LoginController::class, 'forgot_password']); +Route::post('/send_otp', [LoginController::class, 'add_forgot_password']); +Route::get('/otp', [LoginController::class, 'otp_page']); +Route::post('/otp_verify', [LoginController::class, 'verify_otp']); +Route::get('/password_reset', [LoginController::class, 'reset_password_page']); +Route::post('/password_update', [LoginController::class, 'updatePassword']);