Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.9K
Views
How to modify Laravel Jetstream login

I am using Larave Jetstream livewire and I want to modify the login.

login from having a hidden input field "is_admin" with an initial value of 1

when a user submits login form backend check with is_admin = 1 of the database table field


table structure: name, email, password, is_admin

is_admin = 0 or 1

I want to check the is_admin flag, If provided credentials match email, password, and is_admin=1 then only the user can log.


over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I think you intend to customise authentication. Since you are using Jetstream most probably you are using Fortify out of the box (by default).

There are 2 ways. These are to help you sent extra data from your authentication form and not just the hidden field. However, if the is_admin field is default, then I don't think you should add it as hidden field. You could be compromised.

Example 1. Edit the User.php model and add a boot method Fortify::authenticateUsing

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

/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    Fortify::authenticateUsing(function (Request $request) {
        $is_admin = $request->is_admin ?? 1;

        // Your code here ... Example for login in below
        $user = User::where('email', $request->email)->first();

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

    // ...
}

https://laravel.com/docs/8.x/fortify#customizing-user-authentication

Example 2. Also you may edit the app/Providers/FortifyServiceProvider.php

And in the boot method add

Fortify::authenticateUsing(function (Request $request){
    $is_admin = $request->is_admin ?? 1;
    
    // Other codes here
});

Also unless I did not understand you correctly but just want to be sure the user is admin before allowing login, then you could tweak the auth code in Example 1 to do that.

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

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

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

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!