New Password Verification System for Users Logged on to Laravel 6.2

With a new password confirmation feature it works like a GitHub confirmation screen when you perform sensitive actions. Set up Let's consider the new feature so you can see how you're turning in Laravel:

Setup

First, let's create a new Laravel app that will work so you can visualize how this new feature works:

laravel new confirm-appcd confirm-appcomposer require laravel/ui --dev
 Let's create the authorization code for our application:
php artisan ui vue --authyarn installyarn giant

Let's configure an SQLite database later (but you can use the database link you want):
touch database/database.sqlite 

We created the file that Laravel will search by default when using the database link sqlitehowever .envfile through the correct connection and database you will need to update :
DB_CONNECTION=sqlite #... # Use the default path of the sqlite driver#DB_DATABASE=laravel
 Then let's create a test user:
php artisan migrate
We can create a test user with the console factory():
php artisan tinker>>> $user = factory(App\User::class)->create([... 'password' => bcrypt',... 'email' => '[email protected]'... ]);

Let's Write Controllers

Suppose you want users to revalrite their passwords before viewing an administrative action, such as adding an SSH key. We ask the user to re-enter their password in the configured window (the default is 3 hours).

Before the user can create a new key /settings/ssh/createnew password.confirm middleware software for one route we will create:

php artisan make:controller Settings/SSHController
Then, create the controller action
namespaceApp\Http\Controllers\Settings;useApp\Http\Controllers\Controller;useIlluminate\Http\Request;classSSHControllerextendsController{ publicfunctioncreate(){ return view('secret'); }}
opening resources/views/secret.blade.php:
@extends('layouts.app')@section('content')  divclass="container">divclass="row justify-content-center">divclass="col-md-8">h1>Add a New SSH Keyh1>p>This page is shown only after password confirmation.  p>div>div>div>@endsection
During writing auth/passwords/confirm.blade.php file to your project you must copy You can get it here: ui / confirm.stub . Copy this file and add it to your project as follows:
resources/views/auth/passwords/confirm.blade.php
afterward routes/web.php File we need to define the route together with the middleware software that we will need for your identification :
Route::namespace('Settings') ->middleware(['auth']) ->group(function(){ Route::get('/settings/ssh/create', '[email protected]')->middleware('password.confirm'); });
Once you log in with this, you will be redirected to the home page and then ask for your password:

If you followed with this, you will be redirected to create view after the secret, form. Once you have confirmed the password, you can refresh this page without being asked.

Using the New ddd () Helper, add this method to your own method to visualize the auth.password_confirmed_atoturum value that is SSHController::create() to be requested next time:

publicfunctioncreate(){ ddd(session('auth')); return view('secret');}


 In version v6.2.0 config('auth.password_timeout') location area Value how long before you can check the password to confirm it again .config/auth.php

  Quote

KARABAY A, 2021 . New Password Verification System for Users Logged on to Laravel 6.2,

https://www.karabayyazilim.com/blog/php/framework/laravel/laravel-62de-oturum-acmis-kullanicilar-icin-yeni-parola-dogrulama-sistemi-2020-05-31-185401

(Accessed October 15, 2019).


  Share this post

Comments (0)

Comment

Subscribe
Sign up for the email newsletter to be the first to know about my blog posts