Category : laravel-authentication

I am working on a Laravel application where I am using auth sanctum middleware for my front end. One of my modules is based on React. So the following is in the route definition. Route::namespace(‘Api’)->middleware([‘auth:sanctum’])->group(function() { Route::apiResource(‘studios’, StudioController::class); }); Everything is working fine but now I want to allow the anonymous user to use the ..

Read more

I use Laravel 8, and I can’t login in phone.In web it is working correctly. I tried to log user, in web I get the user, but in phone, nothing. Controller if (Auth::attempt($request->only(‘name’, ‘password’), $request->remember)) { return response()->json([‘message’ => true]); } else { return response()->json([‘message’ => false]); } Api Route::get(‘/user’, function (Request $request) { Log::error($request->user()); ..

Read more

I have registration auth in laravel project and i need some existing datas should show up on the registration form , please guide me up.. http://165.232.187.63/register This is my register page and i need to fetch existing database values in the registration form. for example <select> @foreach($users as $items) <option>{{ $items->id }}</option> @endforeach </select> How ..

Read more

I have the following code inside my User model. public static function boot() { parent::boot(); static::creating(function ($model) { if ($user = Auth::user()) { $model->created_by = $user->id; $model->modified_by = $user->id; } }); static::updating(function ($model) { if ($user = Auth::user()) { $model->modified_by = $user->id; } }); } On login, as the remember_token is updated in the user ..

Read more

I am using Laravel 8.x. During password reset request I want to generate custom password reset link /view based on user role. http://127.0.0.1:8000/password/reset/12345678a08ac2df5b18973d8ebb7c9dc1be1faf4cb45686359507d1fbe2ae1?email=test005%40mailinator.com E.g. if a user role is 1 and above is the the URL being generated it should load an admin view, if user role while requesting or generating the request is 2 ..

Read more

i am using laravel 8.5 and trying to setup a custom redirect upon reset password request based on user roles. Currently upon reset password request email is sent and user is sent to homepage. Below is my code in ResetPasswordController under Auth folder protected $redirectTo = RouteServiceProvider::HOME; protected function redirectTo(){ if(Auth::user()->rol==1){ return redirect(‘admin.resetpassword’); } if(Auth::user()->rol==2){ ..

Read more

I’m trying to run this command in Laravel 8.57.0 but it’s not working: PHP artisan make:auth and the error is : Command "make:auth" is not defined Did you mean one of these? make:test make:request make:migration make:seeder make:middleware make:controller make:provider make:policy make:event make:console make:job make:listener make:model make:command I also tried composer require laravel/ui php artisan ui ..

Read more

I am using Laravel fortify to register new users in my web app. I receive payment during registration and it creates a user but I want to show and alert message on home page after login. If I try using return redirect()->route(‘home’)->with(‘success’,’You are logged in!’); it does not work says this method should return a ..

Read more

I have created a laravel project with three guards. Each guard has it’s own provider. For example users are being stored in users table, admins are being stored in admins table and mentors are being stored in mentors table. I am using Laravel passport for authentication. Here are my proviers and guards from config/auth.php ‘guards’ ..

Read more

I have setup a role base authentication for admin and users to be redirected to a different route after registration and login which perfectly well on my local machine but when I deploy to production, it redirects to /home which I have not declared in my web.php FortifyServiceProvider.php $this->app->singleton( LoginResponseContract::class, LoginResponse::class ); $this->app->singleton( TwoFactorLoginResponseContract::class, TwoFactorLoginResponse::class ..

Read more