Unauthenticated exception, can't login

Hi, I'm using Filament to make an admin panel on a website. With the host plan that chose my client, I don't have any access to a terminal or SSH, so I can only do some (not all) artisan command by code with a route. The admin panel works perfectly in local and on another host. To install everything, I just upload all files using FTP (vendor and node_modules included). I get this error when I want to log in, do you have any clew why I get this exception ? Is there something to install related to user and log in ?
No description
Solution:
Ok, it's working, I have to manually put livewire/livewire.js in the public folder :x
Jump to solution
13 Replies
Dennis Koch
Dennis Koch11mo ago
With the host plan that chose my client, I don't have any access to a terminal or SSH
Yeah, that's not really comfortable with Laravel. You really should avoid Shared Hosting.
I get this error when I want to log in, do you have any clew why I get this exception ? Is there something to install related to user and log in ?
Is it really an error? I think Unauthenticated should redirect to the login page
Charly / Toufloux
Charly / TouflouxOP11mo ago
Yeah, for the host, she is my first client, so I didn't really know what to do about the hosting, but I'll change for the next one. It might not be an error, but do you know where this can come from ? It returned to the login page but without any error message :/ I don't think it comes from the model, I have the function set correctly
public function canAccessPanel(Panel $panel): bool
{
return str_ends_with($this->email, '@claire-massagebienetre.fr') && $this->hasVerifiedEmail();
}
public function canAccessPanel(Panel $panel): bool
{
return str_ends_with($this->email, '@claire-massagebienetre.fr') && $this->hasVerifiedEmail();
}
When we do a php artisan make:filament-user, does it modify something in the background ? I create the User from a route with User::create(), do you think it's not a good equivalent ?
Dennis Koch
Dennis Koch11mo ago
No nothing in the background. Just a normal user creation. Did this work locally? Can you verify that both conditions are true on production?
Charly / Toufloux
Charly / TouflouxOP11mo ago
I have another host where I have a terminal (with cPanel), and it works, with the same conditions
Dennis Koch
Dennis Koch11mo ago
Sounds like some issue with the session
Charly / Toufloux
Charly / TouflouxOP11mo ago
I delete all the sessions and views cached in storage>framework to try, nothing changed, what can I search for in the session ? Hey, I'm coming again, I tried another thing : - Take the local files (where filament login works), upload them on my personal host (o2switch, witch cPanel), and only use php artisan storage:link as a command, I upload all the vendor manually to be in the same conditions as the other host.. And surprise, on this host it works ... - So then, I did the same things on the client host (OVH), and since I don't have a terminal or SSH, I did a symlink('../storage/app/public', '../public/storage'); from a route to create the symlink, and no surprise, it keep not working here, with the same unauthenticated and redirect back to the login :x I don't have anymore idea of where to find, if it works on local and other host with the same files, how can this be a code issue ? PS: I tried to login on the o2switch host without any storage link, and with the symlink approach, and both worked on this host
Dennis Koch
Dennis Koch11mo ago
Public storage shouldn't be an issue with authentication. Try debugging without Filament first. If you login a user on a test route Auth::login($user) and then revisit that route, is that user still logged in? Also check whether your session cookie stays the same. Otherwise that means, your session is regenerated every visit
Jordy
Jordy11mo ago
we had a free cPanel thing for school, it is an absolute pain to get a laravel app up.. It is possible, eventually.. but I would recomend stepping away from shared hosting, not for the next project but for this one. its not worth the time and effort and its also pretty frustrating usually
Charly / Toufloux
Charly / TouflouxOP11mo ago
Hi, I tried and the auth worked well with the route, here is the code I used
Route::get('/foo', function () {
echo auth()->user();
});

Route::get('/create-user', function () {
User::create([
'name' => 'Charly',
'email' => '[email protected]',
'password' => Hash::make('testtest123'),
]);
});

Route::get('/login-custom-route', function () {
Auth::login(User::where('name', '=', 'Charly')->first());

echo auth()->user();
});

Route::get('/logout-custom-route', function () {
Auth::logout();

echo (!is_null(auth()->user())) ? auth()->user() : 'Aucun utilisateur connecté';
});
Route::get('/foo', function () {
echo auth()->user();
});

Route::get('/create-user', function () {
User::create([
'name' => 'Charly',
'email' => '[email protected]',
'password' => Hash::make('testtest123'),
]);
});

Route::get('/login-custom-route', function () {
Auth::login(User::where('name', '=', 'Charly')->first());

echo auth()->user();
});

Route::get('/logout-custom-route', function () {
Auth::logout();

echo (!is_null(auth()->user())) ? auth()->user() : 'Aucun utilisateur connecté';
});
In the login, I have my user, if I reload the page, it's still me, in the foo it's me aswell, and if hit the logout, I got the Aucun utilisateur connecté EDIT: So I tried logging in with the client account with the route, and if I go to the /admin, it works a little bit, I'm in the admin panel, but I got a 500 SERVER ERROR, in the log that says [2024-01-19 13:21:36] production.ERROR: Livewire page component layout view not found: [components.layouts.app] {"userId":2,"exception":"[object] (Livewire\\Features\\SupportPageComponents\\MissingLayoutException(code: 0): Livewire page component layout view not found: [components.layouts.app] at /home/clairxn/www/vendor/livewire/livewire/src/Features/SupportPageComponents/SupportPageComponents.php:181) So maybe it's all due to Livewire
Charly / Toufloux
Charly / TouflouxOP11mo ago
Hmmm, so EDIT N°2, if I comment images line, I don't have any errors
Forms\Components\FileUpload::make('monthly_offer_image_path')
->label('Affiche de l\'offre mensuel')
->helperText(new HtmlString('L\'image affiché sur l\'accueil pour l\'offre du mois. <strong>Meilleur taille: 480x640px</strong>'))
->hint(new HtmlString('<a href="https://squoosh.app/" target="_blank" title="Squoosh">Compresse l\'image sur Squoosh (format .avif)</a>'))
->hintColor('primary')
->hintIcon('heroicon-m-photo')
->image(),
Forms\Components\FileUpload::make('monthly_offer_image_path')
->label('Affiche de l\'offre mensuel')
->helperText(new HtmlString('L\'image affiché sur l\'accueil pour l\'offre du mois. <strong>Meilleur taille: 480x640px</strong>'))
->hint(new HtmlString('<a href="https://squoosh.app/" target="_blank" title="Squoosh">Compresse l\'image sur Squoosh (format .avif)</a>'))
->hintColor('primary')
->hintIcon('heroicon-m-photo')
->image(),
By the way, I'm using https://github.com/spatie/laravel-settings
GitHub
GitHub - spatie/laravel-settings: Store strongly typed application ...
Store strongly typed application settings. Contribute to spatie/laravel-settings development by creating an account on GitHub.
Charly / Toufloux
Charly / TouflouxOP11mo ago
I really thinks it's due to Livewire, here is a screenshots of the working panel
No description
Charly / Toufloux
Charly / TouflouxOP11mo ago
And here with the panel that don't work
No description
Solution
Charly / Toufloux
Ok, it's working, I have to manually put livewire/livewire.js in the public folder :x
Want results from more Discord servers?
Add your server