Laravel 5.2 middleware auth not working as I expect - laravel

I've created the basic application used make:auth
I then renamed HomeController to MembersController
When assessing the controller it redirect to the home page but it only does this when
//$this->middleware('auth');
isn't commented. It works fine when uncommented, with the exception theres no authorization.
Any ideas on why its behaving this way

Go to app/Http/Middleware/Authenticate.php then change the redirect URL,where you want to redirect after login

Related

How to redirect to a blade dashboard page from Vue login Component page after successfully login in laravel JetStream?

I created a laravel 8 project using jetstream authentication. As stack I have used inertia+vue. After successful login, I need to redirect to a blade file. But the problem is when I redirect to the blade file, the blade file opens as a modal like the image attached below. And the URL doesn't change (I mean the browser doesn't get refreshed). I would be grateful if you can suggest me the solution. Thanks in advance.
I eventually found this that allowed me to redirect to a page directly from a controller without it appearing in a modal—https://inertiajs.com/redirects#external-redirects.
Example:
return Inertia::location($url);

Laravel Nova: The login form is in HTTP instead of HTTPS

Context
I've installed Laravel Nova, executed the migrations and created the Nova user by following the docs https://nova.laravel.com/docs/3.0/installation.html#installing-nova . Now I'm trying to login.
Expected behavior
When I send the login form, I'm redirected to the backoffice panel.
Actual behavior
When I send the login form, I'm redirected to a Chrome page "This page is not secured, are you sure you want to send your form data?" (approximately the English translation of the French displayed error :D ).
Clues
The login form is shown at this URL: "https://.../nova/login".
The login form, however, contains this action: "http://.../nova/login" - NB: so it's not HTTPS, but HTTP.
Question
Where could I set a Laravel and/or Nova config option to tell Nova to use https instead of http in the action of the login form Nova shows?
Since Nova doesn't seem to use any environment/configuration option to be able to choose the good HTTP/HTTPS protocol, I've directly written the following, in app/Providers/AppServiceProvider (NB: I don't really know the drawbacks of this solution so I don't recommend you to do it, even if in my case it worked well to fix this bug):
public function boot()
{
\URL::forceScheme('https');
}

How to register a route in laravel for SPA admin panel

I am writing a SPA administrative panel site for example (http: // localhost) there you go there a form for entering a login and password, routes laravel handled it and the routes themselves were vue-route
Route::get('/{any}', 'AdminPanelController#index')->where('any', '.*');
Everything works fine, but then I decided to move it to a folder (http: // localhost / admin) and for some reason it does not work
Route::get('/admin/{any}', 'AdminPanelController#index')->where('any', '.*');
If you moved Your whole laravel application, than you'll probably have to adjust your server settings (DocumentRoot). If you moved only your AdminPanelController than I would check if the namespaces are correct. What kind of error are you getting?

Building on Laravel API backend and Vuejs frontend

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').

laravel 5.1: redirecting in AuthController doesn't work (using xampp)

I am using laravel 5.1 and I am trying to make it possible for users to log in to my app. I'm doing this in xampp, so my login path looks like this: http://localhost/laravel/public/index.php/auth/login.
However, when I try to log in it redirects me to http://localhost/auth/login and gives a 404 error. It does this too when the login fails. I have tried to set the 'protected $redirectPath' and 'protected $loginPath' in the AuthController to something like localhost/laravel/public/index.php/ to get to the home page, but it doesn't work and still goes to http://localhost/auth/login. I would be very grateful to anyone that could help me out or explain to me how I can make the redirecting work after logging in or failing to log in.
Just fixed my own problem: it turns out that I was posting my login form to /auth/login (I had just copied the example from the laravel docs), so I changed that to /laravel/public/index.php/auth/login and now everything is acting as it should again!
its better to use
php artisan serve
in your project route if you're developing in localhost because you can control your routes more easily and you can get rid of localhost/laravel/public/index.php/ .

Resources