I followed tutorials and using the below commands I installed all the files needed for register user, login, etc:
composer require laravel/ui
php artisan ui vue --auth
now I have Auth directory in my controllers list and also new forms for register users, login, home and etc are automatically created, I added a link on my page to enter me to registration form, but when I add user, after I hit the register button it says home not found and shows me 404 error which is about route, where I have added Auth::routes(); already to my web blade page. I checked the database, the user is successfully added to the table.
You must add redirectTo property to your auth controller. It's default to /home and you're getting 404 cause you don't have this route.
Related
I am using [statikbe/laravel-cookie-consent] package for cookie policy in my Laravel project and I don't want the modal to be shown on certain pages, so I must add the route to ignored_paths array in the config file. For a route as 'admin/users' every thing is fine but for a route as 'admin/user/{id}' it doesn't work. How can I fix it or how can say all the routes which start with '/admin' don't show the cookie policy?
I've made a new installation of Voyager on XAMPP on Windows following the instructions at https://github.com/the-control-group/voyager
I forgot to install with dummy data so I added an admin user using php artisan voyager:admin me#mydomain.com --create however when I try to login I get the 419 | Page Expired error which I understand is usually an issue with Laravel sessions.
My versions are: Voyager v1.4 | Laravel v7.18 | PHP v7.3.2 | MySql v5.0.12
The following points maybe relevant:
If I look at the login page source code I don't see any reference to a csrf field.
Looking in the database the user exists in the user table, and I entered an email_verified_at date directly.
I notice there's no entry in the user_roles table. I don't know what minimum database entries are required to make it work.
I've checked that session files are being created in storage/framework/sessions/
There's no error log in storage/logs/
I set 'debug' => env('APP_DEBUG', true), in config/app.php (APP_DEBUG was already set to true in .env) and retried the login but not found any debug log file.
I'm new to Voyager and still learning Laravel. Any ideas please how to make it work please?
UPDATE:
After several refreshes of the login page I was able to login, but if I click any menu link it returns me to the login page.
UPDATE2:
Re-running the install with dummy data succeeded but it didn't alter the login session issue. However it works perfectly on another device, so it must be some kind of browser session issue particular to the one PC.
Incidentally running the install with dummy data did not add any entries in the user_roles table, but the admin role is assigned when viewed in the users screen (on my other device).
I was getting this same error, i was serving my app on 127.0.0.1:8000 and my SESSION_DOMAIN was set on localhost. Make Sure you SESSION_DOMAIN in your env is set to the actual domain the app is being served on. Theissue was fixed by running php artisan serve --port=80 and browing to localhost/admin to login
My project crashes on login screen. It tries to get password.request route which it does not see. In routing, there is of course
Auth::routes();
but I did add some other stuff that uses authentication mechanisms. I copied remember password views and controllers from vendors and renamed them to reuse for other purposes.
To be honest I don't even know how to debug missing route. Any help?
You shouldn't have to copy views and controllers from the vendors folder manually if you're doing things with Laravel. Instead run php artisan make:auth in a console. This command will copy the necessary auth blade templates and update your routes/web.php to suit. There is some more info here in the official docs on Laravel authentication.
Also, if you haven't already, you'll need to run migrations by running php artisan migrate in a console. This will create the users and password_resets tables needed to allow registration, login and password recovery.
If you're still having trouble and want to debug things more, make sure you set APP_DEBUG=true inside your .env file in the projects root path. This should record a stack trace in storage/logs/laravel.log when an error occurs.
I would require a little help here if this method will work out well.
Firstly, I have a backend API server created using Laravel and Laravel Passport. Secondly, I have also created the frontend with Vuejs within the same project. As such, I will be required to use both the api.php and web.php routes. I am also redirecting these routes using vue-router.
Backend
Inside the web.php routes, I have used two different routes because I want to display generic contents on my landing site and the other as an authentication required dashboard.
Example:
web.php
As above, this is to capture the routes which are 404 Not Found that are directly manipulated in the address bar to redirect correctly to their respective pages. I also ended up having two different blade templates named as dashboard.blade.php and home.blade.php respectively. Is this an okay practice for a Laravel-Vuejs project? Or are there ways that you would like to recommend?
dashboard.blade.php
home.blade.php
Login related problem with login page using the layout of the landing page into another layout of the dashboard page
The problem that I am faced with when doing an API login with the password grant is that the login page does not redirect to the dashboard page properly. The URL route does change but the page is rendered as blank.
The login using axios here:
I have managed to fix the problem.
In web.php, since we have
Route::get('/dashboard/{any?}', function () {
return view('dashboard');
})->where('any', '^(?!.*api).*$[\/\w\.-]*');
Inside of my Login.vue redirect handler, I use location.href = '/dashboard' instead of this.$router.push('dashboard').
I have set up custom guards for my app using the laravel Auth.
I already have a custom 404.blade.php in resources\views\errors.
Auth::guard('admin')->User() with home route as abc.com/admin
and
Auth::guard('portal')->User() with home route as abc.com/portal
I'm trying to set up 404 pages for them, or at least create a single 404 page with a link to 'home' which should take them to their homepage.
I'm currently on laravel 5.4
Try creating a single blade file for your 404 and put this code in it to redirect to your multiple home pages based on the guard:
#if(Auth::guard("admin")->check())
home
#elseif(Auth::guard('portal')->check())
home
#endif