Stitch
Having issues grabbing user_id using auth-guard:web
Hey nice, that's interesting. What approach would you use personally do you think, if you were to have a public API and have the user accessible site. Sanctum is looking like the best way to handle both tokens for logged in user sessions on the site and API tokens for the public API for each user
42 replies
Having issues grabbing user_id using auth-guard:web
Inside Filament in the Pages folder, and if the Orders.php from the page folder is able to now pull the user_id, I don't see why I shouldn't be able to get the controller to do it instead. Currently looking into livewire though if you think that's a better approach
42 replies
Having issues grabbing user_id using auth-guard:web
Tokens might be the way to go since each user will be having their own API token anyway to access the public API the service I'm building will have. I was looking to integrate this once I had the order controller built https://github.com/jeffgreco13/filament-breezy to make it easy to integrate the necessary features.
Do you think it's worth integrating it now so that I can switch the whole authentication system over to sanctum for both the site and the public API? Also I'm quite new to Laravel and have only just mostly got my head around using controllers etc, haven't really got around to learning livewire yet
42 replies
Having issues grabbing user_id using auth-guard:web
I think this may have been the fix, now it seems to be passing the user_id from app/Fillament/Pages/Orders.php to the controller according to the logging. Ideally it's more secure to pull the user_id in the controller though instead of the fillament page passing it to the controller though right? And yes I'm also using Laravel 11, thank you for your help so far with this
42 replies
Having issues grabbing user_id using auth-guard:web
ddev php artisan route:list ─╯
POST _ignition/execute-solution ignition.executeSolution › Spatie…
GET|HEAD _ignition/health-check ignition.healthCheck › Spatie\LaravelI…
POST _ignition/update-config ignition.updateConfig › Spatie\Larave…
POST api/orders/new ..................... UserOrderController@store
GET|HEAD api/user .....................................................
GET|HEAD filament/exports/{export}/download filament.exports.download …
GET|HEAD filament/imports/{import}/failed-rows/download filament.impor…
GET|HEAD livewire/livewire.js Livewire\Mechanisms › FrontendAssets@ret…
GET|HEAD livewire/livewire.min.js.map Livewire\Mechanisms › FrontendAs…
GET|HEAD livewire/preview-file/{filename} livewire.preview-file › Live…
POST livewire/update livewire.update › Livewire\Mechanisms › Handl…
POST livewire/upload-file livewire.upload-file › Livewire\Features…
ANY login ........ login › Illuminate\Routing › RedirectController
GET|HEAD sMS filament.sMS.pages.dashboard › Filament\Pages › Dashboard
GET|HEAD sMS/deposits-page filament.sMS.pages.deposits-page › App\Fila…
GET|HEAD sMS/login ... filament.sMS.auth.login › Filament\Pages › Login
POST sMS/logout filament.sMS.auth.logout › Filament\Http › LogoutC…
GET|HEAD sMS/orders filament.sMS.pages.orders › App\Filament\Pages\Ord…
GET|HEAD sMS/recent-logins filament.sMS.pages.recent-logins › App\Fila…
GET|HEAD sanctum/csrf-cookie sanctum.csrf-cookie › Laravel\Sanctum › C…
GET|HEAD up ...........................................................
Showing [21] routes
42 replies
Having issues grabbing user_id using auth-guard:web
Replace routes in web.php with what you sent but still getting this issue for some reason
[2024-04-14 21:26:28] local.ERROR: Route [login] not defined. {"exception":"[object] (Symfony\Component\Routing\Exception\RouteNotFoundException(code: 0): Route [login] not defined. at /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:477)
[stacktrace]
42 replies
Having issues grabbing user_id using auth-guard:web
My bad, just applied this to routes/api.php
"<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UserOrderController;
Route::get('/user', function (Request $request) {
return $request->user();
})->middleware('auth:web');
Route::post('/orders/new', [UserOrderController::class, 'store'])->middleware('auth:web');"
But now I'm getting this error, I remember now I removed the middlewear to debug the process up untill fetching the user_id, which is now all going correct apart from fetching the user_id
"[2024-04-14 20:18:58] local.ERROR: Route [login] not defined. {"exception":"[object] (Symfony\Component\Routing\Exception\RouteNotFoundException(code: 0): Route [login] not defined. at /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:477)
[stacktrace]"
42 replies
Having issues grabbing user_id using auth-guard:web
My web.php is as follows
<?php
use Illuminate\Support\Facades\Route;
Route::get('/', function () {
return view('welcome');
});
My api.php is as follows
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UserOrderController;
Route::get('/user', function (Request $request) {
return $request->user();
})->middleware('auth:web');
Route::post('/orders/new', [UserOrderController::class, 'store']);
42 replies
Having issues grabbing user_id using auth-guard:web
The controller is used to store the user order and fetch details from a external API to store to the DB, everything up until that point is fine as evidenced by the logging I've done in laravel.log, except for grabbing the correct user_id that made the order. I'm requesting the controller from my Order.php page in app/Filament/pages/Orders.php
42 replies