Admin dashboard login

This commit is contained in:
sayliraut
2024-05-23 16:41:29 +05:30
parent f1704116b3
commit 57c20431f1
35 changed files with 1406 additions and 13 deletions

View File

@@ -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);
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class CheckStatus
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
$admin = auth()->guard('admin')->user();
if ($admin && $admin->is_active == 1) {
return $next($request);
} else {
return redirect('/')->with('error_msg', 'You must be logged in..');
}
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class AdminPasswordResetEmail extends Mailable
{
use Queueable, SerializesModels;
public $data;
/**
* Create a new message instance.
*/
public function __construct($data)
{
$this->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<int, \Illuminate\Mail\Mailables\Attachment>
*/
public function attachments(): array
{
return [];
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class IamAppAction extends Model
{
use HasFactory;
use SoftDeletes;
protected $table = 'iam_app_action';
protected $dates = ['deleted_at'];
protected $fillable =
[
'action_name',
'is_active'
];
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class IamAppResource extends Model
{
use HasFactory;
use SoftDeletes;
protected $table = 'iam_app_resource';
protected $dates = ['deleted_at'];
protected $fillable =
[
'app_resource_title',
'is_active'
];
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class IamAppResourceActionLink extends Model
{
use HasFactory;
use SoftDeletes;
protected $table = 'iam_app_resource_action_link';
protected $dates = ['deleted_at'];
protected $fillable =
[
'app_resource_xid',
'app_action_xid',
'is_active'
];
}

View File

@@ -19,8 +19,8 @@ class IamPrincipal extends Model
use SoftDeletes;
use HasApiTokens, HasFactory, Notifiable;
use HasFactory;
protected $table = 'iam_principal';
// protected $dates = ['deleted_at'];
protected $fillable = [
'one_signal_player_id',
@@ -39,4 +39,133 @@ class IamPrincipal extends Model
'notification_status',
'deleted_by_admin'
];
public function moduleLinks()
{
return $this->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<int, string>
*/
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
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');
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class IamPrincipalOtp extends Model
{
use HasFactory;
use SoftDeletes;
protected $table = 'iam_principal_otp';
protected $dates = ['deleted_at'];
protected $fillable = [
'principal_xid',
'otp_code',
'otp_purpose',
'valid_till',
'is_used',
'is_active'
];
public function getPrincipal()
{
return $this->belongsTo(IamPrincipal::class, 'principal_xid', 'id')->withDefault();
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class IamPrincipalRestaurantRole extends Model
{
use HasFactory;
protected $table = 'iam_principal_restaurant_role';
protected $fillable = [
'principal_xid',
'restaurant_xid',
'role',
'created_by',
'modified_by',
];
}

View File

@@ -0,0 +1,29 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class IamPrincipalSource extends Model
{
use HasFactory;
use SoftDeletes;
protected $table = 'iam_principal_source';
protected $dates = ['deleted_at'];
protected $fillable =
[
'principal_source_title',
'is_active'
];
public function iamPrincipals()
{
return $this->hasMany(IamPrincipal::class, 'principal_source_xid', 'id');
}
public function source(){
return $this->hasOne(IamPrincipal::class,'id','principal_source_xid');
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class IamPrincipalType extends Model
{
use HasFactory;
use SoftDeletes;
protected $table = 'iam_principal_type';
protected $dates = ['deleted_at'];
protected $fillable =
[
'principal_type_title',
'is_active'
];
public function iamPrincipals()
{
return $this->hasMany(IamPrincipal::class, 'principal_type_xid', 'id');
}
public function type(){
return $this->hasOne(IamPrincipal::class,'id','principal_type_xid');
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class IamResourceActionLink extends Model
{
use HasFactory;
use SoftDeletes;
protected $table = 'iam_resource_action_link';
protected $dates = ['deleted_at'];
protected $fillable =
[
'role_xid',
'app_resource_action_xid',
'is_active'
];
}

View File

@@ -14,8 +14,8 @@ return [
*/
'defaults' => [
'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,
]
],
/*

View File

@@ -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();

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('iam_principal_group', function (Blueprint $table) {
$table->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');
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('iam_principal_principal_group_link', function (Blueprint $table) {
$table->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');
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('iam_principal_biometric', function (Blueprint $table) {
$table->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');
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('iam_app_resource', function (Blueprint $table) {
$table->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');
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('iam_app_action', function (Blueprint $table) {
$table->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');
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('iam_app_resource_action_link', function (Blueprint $table) {
$table->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');
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('iam_role', function (Blueprint $table) {
$table->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');
}
};

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('iam_principal_role_link', function (Blueprint $table) {
$table->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');
}
};

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('iam_resource_action_link', function (Blueprint $table) {
$table->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');
}
};

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('iam_principal_otp', function (Blueprint $table) {
$table->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');
}
};

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('iam_principal_restaurant_role', function (Blueprint $table) {
$table->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');
}
};

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('iam_principal', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('iam_principal');
}
};

105
resources/lang/en/auth.php Normal file
View File

@@ -0,0 +1,105 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are used during authentication for various
| messages that we need to display to the user. You are free to modify
| these language lines according to your application's requirements.
|
*/
'logout'=>'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.'
];

View File

@@ -0,0 +1,37 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Success Message Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are used during authentication for various
| messages that we need to display to the success. You are free to modify
| these language lines according to your application's requirements.
|
*/
'payment_intent_created'=>'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',
];

View File

@@ -0,0 +1,90 @@
@extends('admin.layouts.app_login')
@section('title', 'Forgot Password')
@section('content')
<div class="row w-100" style="height: 100vh;">
<div class=" col-md-6 m-auto h-100 d-flex flex-column align-itms-center justify-content-center"
style="background-color: #05244D;">
<div class="d-flex justify-content-center">
<img src="{{ asset('assets/img/seasons_logo.png')}}" width="150" height="150" alt="">
</div>
</div>
<div class=" col-md-6 h-100 d-flex justify-content-center align-items-center login-background-img"
style="background-image: url(publicassets/img/login_screen_background.png);">
<div class="row d-flex flex-column justify-content-center align-items-center m-auto"
style="width: 60%; z-index: 999;">
<h4 class="text-start font-weight-bold mb-3 text-white">FORGOT PASSWORD</h4>
<form id="forgot_pass_form">
<div class="col-md-12">
<div class="mb-3 input-parent">
<i class="fa fa-envelope" aria-hidden="true"></i>
<input type="email" class="form-control" name="email" placeholder="Email Address">
</div>
</div>
<div class="col-md-12">
<div>
<button type="Submit" id="forgot_password_btn" class="p-0 download-btn">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div>
@endsection
@section('scripts')
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.5/jquery.validate.min.js"></script>
<script>
$(document).on("click", "#forgot_password_btn", function (e) {
let base_url = url_path;
$('#forgot_pass_form').validate({
ignore: [],
debug: false,
rules: {
email: {
required: true
}
},
messages: {
email: {
required: "Please Enter email"
}
},
submitHandler: function (form) {
var formData = new FormData(form);
e.preventDefault(),
$.ajaxSetup({
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
},
});
$.ajax({
url: base_url + '/send_otp',
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function (response) {
console.log(response);
if (response.status_code == 200) {
form.reset();
toastr.success('Otp send it your mail id please check');
setTimeout(function () {
// toastr.info('Please check your email to reset your password. The link is valid for 5 minutes.');
window.location.href = base_url + "/otp";
}, 1000);
}else if (response.status == 404) {
toastr.error('This email id is not exits');
}
else {
toastr.error(response.message);
}
},
});
}
});
});
</script>
@endsection

View File

@@ -0,0 +1,91 @@
@extends('admin.layouts.app_login')
@section('title', 'Cheers To Season - Otp')
@section('content')
<div class="row w-100" style="height: 100vh;">
<div class=" col-md-6 m-auto h-100 d-flex flex-column align-itms-center justify-content-center"
style="background-color: #05244D;">
<div class="d-flex justify-content-center">
<img src="{{ asset('assets/img/seasons_logo.png')}}" width="150" height="150" alt="">
</div>
</div>
<div class=" col-md-6 h-100 d-flex justify-content-center align-items-center login-background-img"
style="background-image: url(assets/img/login_screen_background.png);">
<div class="row d-flex flex-column justify-content-center align-items-center m-auto"
style="width: 60%; z-index: 999;">
<h4 class="text-start font-weight-bold text-white">VERIFICATION CODE</h4>
<h5 class="text-white mb-3">Please enter the OTP</h5>
<form id="otpVerificationForm">
<div class="col-sm-12 bgWhite">
<input type="hidden" name="time" value="{{ session('admin_data.valid_till') }}">
<input type="hidden" id="admin_otp_id" name="id" value="{{ session('admin_data.principal_xid') }}">
<input class="otp" type="text" name="digit1" maxlength="1">
<input class="otp" type="text" name="digit2" maxlength="1">
<input class="otp" type="text" name="digit3" maxlength="1">
<input class="otp" type="text" name="digit4" maxlength="1">
</div>
<div class="col-md-12">
<div>
<button type="submit" id="otp_verify_button" class="download-btn w-100">Submit</a></button>
</div>
</div>
</form>
</div>
</div>
</div>
@endsection
@section('scripts')
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.5/jquery.validate.min.js"></script>
<script>
$(document).on('click', '#otp_verify_button', function(e) {
e.preventDefault();
// Get base URL
let base_url = url_path;
// Get admin ID
var id = $('#admin_otp_id').val();
// Get OTP by concatenating values of all OTP input fields
var otp = $('.otp').map(function() {
return this.value;
}).get().join('');
// Send AJAX request for OTP verification
$.ajax({
url: base_url + '/otp_verify',
type: 'POST',
data: {
id: id,
otp: otp,
'_token': $('meta[name="csrf-token"]').attr('content')
},
success: function (response) {
if (response.status_code == 200) {
// Display success message
toastr.success('Otp Verify Successfully');
// Redirect to the dashboard after a delay
setTimeout(function () {
window.location.href = base_url + "/password_reset";
}, 1000);
} else if (response.status == 401) {
toastr.error(response.message);
} else {
toastr.error(response.message);
}
},
});
});
$(document).on('input', '.otp', function() {
this.value = this.value.replace(/[^0-9]/g, '');
if (this.value.length >= this.maxLength) {
$(this).next('.otp').focus();
}
});
</script>
@endsection

View File

@@ -0,0 +1,143 @@
@extends('admin.layouts.app_login')
@section('title', 'Cheers To Season - Password Reset')
@section('content')
<div class="row w-100" style="height: 100vh;">
<div class=" col-md-6 m-auto h-100 d-flex flex-column align-itms-center justify-content-center"
style="background-color: #05244D;">
<div class="d-flex justify-content-center">
<img src="{{ asset('assets/img/seasons_logo.png') }}" width="150" height="150" alt="">
</div>
</div>
<div class=" col-md-6 h-100 d-flex justify-content-center align-items-center login-background-img"
style="background-image: url(assets/img/login_screen_background.png);">
<div class="row d-flex flex-column justify-content-center align-items-center m-auto"
style="width: 60%; z-index: 999;">
<h3 class="text-start font-weight-bold mb-3 text-white">RESET PASSWORD</h3>
<form id="password_reset_form">
<div class="col-md-12">
<div class="mb-3 input-parent">
<i class="fa fa-lock" aria-hidden="true"></i>
<input type="hidden" id="admin_otp_id" name="reset_id"
value="{{ session('admin_data.principal_xid') }}">
<input type="password" class="form-control" name="password" placeholder="Password">
</div>
</div>
<div class="col-md-12">
<div class="mb-3 input-parent">
<i class="fa fa-lock" aria-hidden="true"></i>
<input type="password" class="form-control" name="confirm_password" id="password"
placeholder="Confirm Password">
</div>
</div>
<div class="col-md-12">
<div>
<button type="submit" id="password_reset" class="p-0 download-btn w-100">Login</button>
</div>
</div>
</form>
</div>
</div>
</div>
@endsection
@section('scripts')
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.5/jquery.validate.min.js"></script>
<script>
$(document).ready(function() {
// Password visibility toggle
$('#passwordToggle').click(function() {
var passwordInput = $('#password');
var eyeIcon = $('#passwordToggle');
if (passwordInput.attr('type') === 'password') {
passwordInput.attr('type', 'text');
eyeIcon.removeClass('fa-eye-slash').addClass('fa-eye');
} else {
passwordInput.attr('type', 'password');
eyeIcon.removeClass('fa-eye').addClass('fa-eye-slash');
}
});
// Form validation and submission
$('#password_reset_form').validate({
rules: {
password: {
required: true,
minlength: 8
},
confirm_password: {
required: true,
equalTo: "#password"
},
},
messages: {
password: {
required: "Please enter a password.",
minlength: "The password field must be at least 8 characters."
},
confirm_password: {
required: "Please Confirm Your Password",
equalTo: "Your Password Do Not Match"
},
},
invalidHandler: function(event, validator) {
var errors = validator.errorList;
$.each(errors, function(index, error) {
toastr.error(error.message);
});
},
submitHandler: function(form) {
let base_url = url_path;
var formData = new FormData(form);
$.ajaxSetup({
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
},
});
$('#password_reset').prop('disabled', true).text('Processing...');
$.ajax({
url: base_url + '/password_update',
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function(response) {
if (response.status_code == 200) {
toastr.success(response.message);
window.location.href = base_url + "/";
} else if (response.status_code == 401) {
toastr.error(response.message);
form.reset();
}
$('#password_reset').prop('disabled', false).text('Sign In');
},
error: function(xhr) {
if (xhr.status === 422) {
var errors = xhr.responseJSON.message;
$.each(errors, function(index, value) {
toastr.error(value);
});
} else {
toastr.error('An unexpected error occurred. Please try again.');
}
$('#password_reset').prop('disabled', false).text('Sign In');
}
});
}
});
$(document).on("click", "#password_reset", function(e) {
e.preventDefault();
$('#password_reset_form').submit();
});
});
</script>
@endsection

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>OTP Email</title>
</head>
<body>
<h1>Your OTP Code</h1>
<p>Your OTP code is: <strong>{{ $content['otp_code'] }}</strong></p>
<p>This code will expire in a short period, so please use it promptly.</p>
</body>
</html>

View File

@@ -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']);