DEV Community

Cover image for Login Customization in Laravel 8

Posted on • Updated on

Login Customization in Laravel 8


this time I can still write an article that hopefully can be useful for friends who read...

As the title implies, I want to share a little about Login Customization in Laravel 8

💡 Laravel 8 Update Info

Laravel has just updated to version 8 which brings a lot of new things, like using it TailwindCSS, Livewire, Folder Models, Jetstream, Factory Updates, and others ... You can read it yourself at

With Jetstream, Laravel has removed the Laravel UI which was previously used in Laravel 6 and 7 as its Authentication Scaffold

Well .. Because of these changes, automatic customization for the login is different. Files that we usually encounter like LoginController.php are no longer in Laravel 8. Here are some Ways that have been found to customize Login in Laravel 8:

📬 Change the Email Input when Login

  1. Go to Folder config > fortify.php
  2. On Line 45 (Default) there is a key "username" => "email". Change the email to whatever you want, for example, username. So it becomes "username" => "username". That way you can log in using a username and password without the need for email. Of course it must also be adjusted to those in database.

🔓 Changing the Route / Destination After Successfully Login

  1. Go to Folder app > Providers > RouteServiceProvider.php
  2. Change the "/ dashboard" as desired on line 20

public const HOME = '/ dashboard';

after successful login it will go to the route you point here

🔐 Change the Minimum Requirement Password when registering

By default in Laravel 8, if we want to register then the password is at least 8 characters to change it:

  • Go to vendor > laravel > fortify > src > Rule > Password.php
  • Change protected $ length = 8; As you wish, for example 10
  • And if you want when registering, the password must have an Uppercase character, just change it $requireUppercase from false to true
  • And if you want to register, the password must be a number, just change $requireNumeric from false to true

✍️ Change Validation Language when Login & Register Error

  • Still in the same FIle as the previous step
  • Just scroll down a bit and you will see function message ()
  • Change the existing string in the function. to the language you want


❤️ Create Your Own Login Controller

So, for those of you who want to create your own login controller, you can follow these steps:

  • Create a file with the name LoginController.php in app > Http > Controllers. Actually for the controller name free. Just an example so that it fits its function.
  • then paste the following code in it
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class LoginController extends Controller{
    public function authenticate(Request $request){
        // Retrive Input
        $credentials = $request->only('email', 'password');

        if (Auth::attempt($credentials)) {
            // if success login

            return redirect('berhasil');

            //return redirect()->intended('/details');
        // if failed login
        return redirect('login');
Enter fullscreen mode Exit fullscreen mode
  • Change the part that I comment on the you wish
  • Add routes at routes > web.php Example:

Route::post('logged_in', [LoginController::class, 'authenticate']);

  • Change action attributes in login views and point to route

By creating your own Login Controller, you can also change your email to a username / other as you wish. Just change the text of the email in the $ credentials from the code I provided above.

⌛️ Closing

Ok, how? Already familiar with Authentication in Laravel 8? Actually there are many other Authentication configurations that can be changed.

So Hopefully Helpful ..

Thank you 👊

Top comments (20)

lootfi profile image

Thanks for the post!

One remark on the "Change the Minimum Requirement Password" part

you should never mess with your vendor files unless you are pushing them to production.

Here's how you can customize the minimum requirement:

aibnuhibban profile image
AibnuHibban • Edited

Yeah .. Thanks for reminding .. 👌

bodnarlajostibor profile image

I'm facing the same issue, but that Jetstream documentation is unclear for me.

Can you please help me where to put there codes like "(new Password)->length(10)"?

lootfi profile image

You can do that in "App\Actions\Fortify\PasswordValidationRules" where you will find a "passwordRules" method

Thread Thread
bodnarlajostibor profile image

An in that, I can see one line:
return ['required', 'string', new Password, 'confirmed'];

Where should I put the suggested "(new Password)->length(10)", for example?

Thread Thread
tuckbloor profile image

protected function passwordRules()
you need to add the following

return ['required', 'string', (new Password)->length(10), 'confirmed'];
Enter fullscreen mode Exit fullscreen mode
aregonyazilim profile image

I used the following code;

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Laravel\Fortify\Fortify;

class LoginController extends Controller
public function authenticate(Request $request)

    Fortify::authenticateUsing(function (Request $request) {

        $user = User::where('email', $request->email)->first();

        if ($user && Hash::check($request->password, $user->password)) {
            return $user;


But it doesn't work. Where am I going wrong?

lootfi profile image

Maybe your login form action is not making a request to your LoginController?

Route::post('authenticate', [LoginController::class, 'authenticate'])->name('authenticate');
<form method="POST" action="{{ route('authenticate') }}">
oceanrational profile image

Well. It's good you trying it on newer version. unfortunatly i havent tried yet. I hope someone will definitly answer this.

aibnuhibban profile image

Are you routing the controller correctly?
If there is an error what is the error?

localpath profile image
Garrick Crouch

You should override the properties on the vendor class, it includes a setter ->


namespace App\Actions\Fortify;

use Laravel\Fortify\Rules\Password;

trait PasswordValidationRules

     * Get the validation rules used to validate passwords.
     * @return array
    protected function passwordRules()
        return ['required', 'string', (new Password())->length(6), 'confirmed'];
Enter fullscreen mode Exit fullscreen mode
mafalda2007 profile image

Hi, very good!
If I want to have two places to authenticate the user? how would it be?

  1. The user must login to the local database (this is my new DB).
  2. In case of error, validate in the second remote database via Webservice. (this's de old old old DB)
seddka profile image
Seddik Tagadirt

Thanks for the post! nice article Abdullah.
I have a question: Can i specify multiple guards in fortify? by default it uses web guard, but what if i have and admin in my Auth config and wants to make use of it with fortify? any ideas?

javierx2010 profile image
Javier Escobar

Dude! You are awesome! I spent days trying to find answers on Stackoverflow and Laracast and you solved all my questions in a condensed yet wonderful post!

Thanks a lot!

alarafatsiddique profile image

What about RegisterController? Can u please clear it like i did for loginController...

moduledev profile image

Thanks a lot for article! But can you explain how to make custom register (for instance we want to use several models User,Admin)?

4n_najib profile image
An Najib

how about creating remember me token when login. I want to manualy create theme

Some comments may only be visible to logged-in visitors. Sign in to view all comments.