The problem is this: One subdomain admin.domain.com and a laravel app installed here with auth.
Everything is good until I press login or register button and I get "File not found.". I have ssh control and cpanel control for the server. I read everything on google and stackoverflow but nothing helped me.
If it helps, I tried to route the registration page to '/' and it works but when I press the register button 'File not found'. To mention that i didn't modified anything, i only create the app via "laravel new App --auth"
So this is working
Route::get('/', function () {
return view('welcome');
});
Related
I made an authentication system using Laravel sanctum and Fortify for the authentication and Angular for the frontend.
The problem is that after logging in I need to redirect to my frontend homepage, I tried this solutions but they didn't work:
setting fortify home parameter as:
'home' => 'http://127.0.0.1:4200/',
making the home route in Laravel redirect to this url (results in a core problem from my frontend)
Route::middleware('auth:sanctum')->get('/home', function (){
return Redirect::away('http://127.0.0.1:4200');
});
how should I do this? is there something I need to do with sanctum?
I was trying to follow a simple tutorial. I think I installed everything correctly and when I run the virtual machine, the laravel homepage shows up. I also added this in the web.php code:
Route::get('/home', function(){
return "This is the home page";
});
If I followed the tutorial video then doing [website.com]/home , It will just print a string saying "This is the home page" But when I save and launch it, it comes up with a 404 error. I dont see what the problem is and I apologise for just being a beginner with this.
I'm trying to check if the user is logged in or not when accessing subdomain, if not then enforce the user to login into the main domain.
Below is the process which I followed.
Changes I made in .env file as
SESSION_DOMAIN=mac.local
SESSION_DRIVER=database
and ran the migration for sessions using php artisan session:table.
Menu link:
Dev subdomain
Routes:
Route::domain('{account}.' . env('SESSION_DOMAIN'))->group(function () {
Route::get('/', 'HomeController#subdomainAsset')->name('asset');
});
I have a fresh laravel project installed at dev.mac.local.
dev.mac.local is loading even I did not login into mac.local.
How do I keep a check to ensure the user should log in before they access this subdomain dev.mac.local, if not return a message to log in before access this subdomain?
Any suggestions, please.
I am having a problem with accessing the Auth::user() in a Laravel package routes file.
I am creating a package for Laravel (using 5.8.9). The package has its own routes in a route file which is being added correctly.
I have created an identical route in the main test site and the package. I am using composer 'path' to symlink the package into the test site which is on Homestead that I'm using on a windows 10 computer.
The route is simple and I'm just checking to see if a user is logged in, which it is.
Route::get('/home', function () {
dd(Auth::check());
});
In the main site routes file the check is returning true as expected. When commented out and allowing the route file in the package to handle it we get a return of false.
I noticed it as was getting an error when trying to run middleware on the package and after some investigating found that the package is not registering the user as being logged in.
Any ideas? Is it a problem because I'm using the path on composer to symlink?
EDIT: OK I've ruled out the symlink being the problem by creating a private repo and importing it. So its now in the vendor as a normal imported package but still getting the same issue.
EDIT2: I just tried to pull a user in the package routes file by just doing a simple
Route::get('/home', function () {
$user = \App\User::find(1);
dd($user);
});
And get null does anyone know if its possible to access the user/core laravel models in a package or is it disabled or a problem with the load order?
I managed to resolve it, if you use routes that require auth in your packages then you need to include the web middleware. If you do not include the web middleware then you are not loading some of the functionality that the main framework will load, like sessions.
And if you don't have sessions then obviously you wont be able to retrieve logged in users.
So to get it working you would change the code to
Route::get('/home', function () {
$user = \App\User::find(1);
dd($user);
})->middleware(['web']);
I've created a project and programmed most the content locally until I've got a server. Now I have a server and I moved the files to the server. After I've got the project run normally, I've got in trouble with the authentification. ( I added the authentification on the server, it wasn't there locally ).
Every time I try to login or to register I only get redirected to the login/register route without any error or something like that. The DB connection works fine, I've tried getting some data from it and that worked.
I looked for the auth routes and tried to return the HTTP header data in the register function but the program doesn't reach this function at all.
I also tried to overwrite the register post Route in Router.php in /vendor/framework/src/Illuminate/Routing/Router.php from:
$this->post('register', 'Auth\RegisterController#register');
to
$this->post('register', 'TestController#test');
Just to look if in the #test function in my TestController will be reached, but nothing. Got redirected again.
However, I haven't changed the auth controller etc. at all besides, the redirect route in the login/register-controller
Here are my routes in my web.php:
Route::group(['middleware' => 'auth', 'web'], function () {
// my routes - the user shall only see them if they are logged in
});
Auth::routes();
If I log a user manually in, everything works fine
I really have no clue what to do anymore, does someone have a clue?
php artisan route:list :