πŸš€ DevOps & SRE Certification Program πŸ“… Starting: 1st of Every Month 🀝 +91 8409492687 πŸ” Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

How to Generate New Password in Laravel?

How to Generate New Password in Laravel?

Step 1. Create a new Project in Laravel, so Open git Bash. Write down the following command:-

$ composer create-project --prefer-dist laravel/laravel changepassword "5.8.*"

Step 2. Now, Move to project directory on git Bash, so write down the following command:-

$ cd changepassword

Mysql Database connection Laravel

Step 3. Now, we have to Create a new DatabaseGo to XAMPP server->phpMyAdmin->Click New Database->changepassword.

Step 4. Now, Go to .env file to set the project path and give the project APP_URL, DB_DATABASE name and DB_USERNAME name.

Step 5.  Create the user authentication scaffoldingWrite down the following command:-

$ php artisan make:auth

Step 6.  Thereafter, Migrate tables into the MySQL databaseWrite the following command within git Base.

$ php artisan migrate

Step 7. Go to app/Http/Controller/HomeController.php file and write down this following code:-

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Hash;
use Auth;
use Session;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
return view('home');
}
public function changePasswordUpdate(Request $request)
{
if(!(Hash::check($request->get('current_password'),Auth::user()->password))){
return back()->with('error','Your current password does not match what you provided');
}
if(strcmp($request->get('current_password'), $request->get('new_password'))==0){
return back()->with('error','Your new password cant be same with your current password');
}
$request->validate([
'current_password'=>'required',
'new_password'=> 'required|string|min:6|confirmed'
]);
$user = Auth::user();
$user->password = bcrypt($request->get('new_password'));
$user->save();
return back()->with('message','Password changed Successfully');
}
}

Step 8. Go to resources/views/home.blade.php file and write down this following code:-

@extends('layouts.app')
@section('content')
<div class="container">
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach($errors->all() as $error)
<li>
{{$error}}
</li>
@endforeach
</ul>
</div>
@endif
@if(session('error'))
<div class="alert alert-danger" role="alert">
{{session('error')}}
</div>
@endif
@if(session()->get('message'))
<div class="alert alert-success" role="alert">
<strong>Success: </strong>{{session()->get('message')}}
</div>
@endif
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{Auth::user()->name}}'s Dashboard</div>
<div class="card-body">
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif
@if($message = Session::get('success'))
<div class="alert alert-success">
<p>{{$message}}</p>
</div>
@endif
<form action="{{route('home')}}" method="POST">
@csrf
<div class="form-group">
<label for="current_password"><strong>Current Password:</strong></label>
<input type="password" class="form-control" id ="current_password" name="current_password">
</div>
<div class="form-group">
<label for="new_password"><strong>New Password:</strong></label>
<input type="password" class="form-control" id ="new_password" name="new_password">
</div>
<div class="form-group">
<label for="new_password_confirmation"><strong>Confirm New Password:</strong></label>
<input type="password" class="form-control" id ="new_password_confirmation" name="new_password_confirmation">
</div>
<button class="btn btn-primary" type="submit">Generate New Password</button>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection

Step 9. Go to Route/web.php file and write down this following code:-

Route::post('/home', 'HomeController@changePasswordUpdate')->name('home');

Login

Checking the current password matches or not with the provided password

Checking new password should not be same with the current password

Password changed Successfully

Thanks

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.