So I am trying to create a 'magic' link type feature that I could send to clients to onboard that logs them directly into the LMS I'm creating. So I created a middleware with code as so:
https://gist.github.com/HeadStudios/c056f6da5992599dc2dc9ee824f31b74
Anyway that works fine with magic link from route as so:
Route::get('/vlesson/{perma}', [CourseController::class, 'vlesson'])->middleware('magic');
it logs them in and show them their personalised stuf... now here's where the issue comes in... the login WON'T stick. So for example if I open up a new tab in my browser and go into Laravel Nova... they're not logged in.
I tested and if I execute the same code in a route:
e.g.
Route::get('/authentifer', function() {
Auth::loginUsingId(1, true);
return "Now we are in forever!";
});
It logs me in without issue in the sense that i can open up new tabs and my session is across all the windows and I'm logged in properly. At first I thought it was Middleware so I even added this code to the ACTUAL blade view:
<?php
use App\Models\Checklist;
use App\Models\User;
use App\Models\Course;
use App\Models\Vlesson;
use App\Http\Controllers\CourseController;
use Illuminate\Support\Facades\Auth;
Auth::loginUsingId(1, true);
$course = CourseController::getCourseForLesson($user->id, $vlesson->id);
echo $course->name;
die();
$user_id = $user->id;
$course_id = 2;
...
But even with this view... it STILL doesn't log me in and permeate the sessions across different windows... so... is there any way to log a person in and keep them consistently logged in when using the view/controller/middleware fraework.
Any input would be much appreciated. Thank you!