added pass change option

Cette révision appartient à :
Ibrahim Khail Shakil 2023-12-18 12:31:40 +06:00
Parent 4140765998
révision 62293c350d
5 fichiers modifiés avec 34 ajouts et 8 suppressions

Voir le fichier

@ -5,6 +5,7 @@
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\Student; use App\Models\Student;
use Illuminate\Support\Facades\Hash;
class ProfileController extends Controller class ProfileController extends Controller
{ {
@ -45,6 +46,29 @@ public function save_profile(Request $request)
} }
} }
public function change_password(Request $request)
{
try {
$data = Student::find(currentUserId());
// Validate current password
if (!Hash::check($request->current_password, $data->password)) {
return redirect()->back()->with('error', 'Current password is incorrect.');
}
$data->password = Hash::make($request->password);
$data->language = 'en';
if ($data->save()) {
$this->setSession($data);
return redirect()->back()->with('success', 'Data Saved');
}
} catch (Exception $e) {
// dd($e);
return redirect()->back()->withInput()->with('error', 'Please try again');
}
}
public function setSession($student) public function setSession($student)
{ {
return request()->session()->put( return request()->session()->put(

Fichier binaire non affiché.

Après

Largeur:  |  Hauteur:  |  Taille: 71 KiB

Voir le fichier

@ -220,12 +220,13 @@ class="text-secondary">Dashboard</a></button>
<div class="white-bg mt-4"> <div class="white-bg mt-4">
<div class="students-info-form"> <div class="students-info-form">
<h6 class="font-title--card">Change Password</h6> <h6 class="font-title--card">Change Password</h6>
<form action="#"> <form action="{{route('change_password')}}" method="post">
@csrf
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<label for="cpass">Current Password</label> <label for="current_password">Current Password</label>
<div class="input-with-icon"> <div class="input-with-icon">
<input type="password" id="cpass" class="form-control" <input type="password" id="cpass" name="current_password" class="form-control"
placeholder="Enter Password" /> placeholder="Enter Password" />
<div class="input-icon" onclick="showPassword('cpass',this)"> <div class="input-icon" onclick="showPassword('cpass',this)">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"
@ -242,9 +243,9 @@ class="text-secondary">Dashboard</a></button>
</div> </div>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<label for="npass">New Password</label> <label for="password">New Password</label>
<div class="input-with-icon"> <div class="input-with-icon">
<input type="password" id="npass" class="form-control" <input type="password" id="npass" name="password" class="form-control"
placeholder="Enter Password" /> placeholder="Enter Password" />
<div class="input-icon" onclick="showPassword('npass',this)"> <div class="input-icon" onclick="showPassword('npass',this)">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"
@ -261,9 +262,9 @@ class="text-secondary">Dashboard</a></button>
</div> </div>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<label for="cnpass">Confirm New Password</label> <label for="password_confirmation">Confirm New Password</label>
<div class="input-with-icon"> <div class="input-with-icon">
<input type="password" id="cnpass" class="form-control" <input type="password" id="cnpass" name="password_confirmation" class="form-control"
placeholder="Enter Password" /> placeholder="Enter Password" />
<div class="input-icon" onclick="showPassword('cnpass',this)"> <div class="input-icon" onclick="showPassword('cnpass',this)">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"

Voir le fichier

@ -85,6 +85,7 @@
Route::get('/dashboard', [studashboard::class, 'index'])->name('studentdashboard'); Route::get('/dashboard', [studashboard::class, 'index'])->name('studentdashboard');
Route::get('/profile', [stu_profile::class, 'index'])->name('student_profile'); Route::get('/profile', [stu_profile::class, 'index'])->name('student_profile');
Route::post('/profile/save', [stu_profile::class, 'save_profile'])->name('student_save_profile'); Route::post('/profile/save', [stu_profile::class, 'save_profile'])->name('student_save_profile');
Route::post('/profile/savePass', [stu_profile::class, 'change_password'])->name('change_password');
Route::post('/change-image', [stu_profile::class, 'changeImage'])->name('change_image'); Route::post('/change-image', [stu_profile::class, 'changeImage'])->name('change_image');
/* ssl payment */ /* ssl payment */