Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.9K
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda