'Store link in localstorage before Laravel auth middleware redirect
I'm creating an invitation link for a laravel application, once a user clicks on the link or tries to access the link I want a path of the link to be stored in localStorage. This is what the link looks like https://example.com/{task_id}/{random_task_link}, I want the random_task_link to be stored in the localStorage. I have a code to do it using js but that is not the case. I used the code below to ensure that the user is logged in before they can access the link page
public function __construct(){
$this->middleware('auth');
}
Now the localStorage code won't work because the page gets redirected before it is accessed. The main purpose of storing the link in the localStorage is to make sure that when a user clicks on the registration link the random_task_link is still available for future use.
Is there any way to get the link in the localStorage before the redirect takes place? Please help me I'm new to laravel. Thanks
Solution 1:[1]
i dont get your points there are lots of ways and points where you can store the data in localStorage
first when you are creating the url save at the same time in the localStorage
second make another middleware and call it before the auth middleware or apply just on some specific route
third take this auth middleware to route level and even if grouped you can use Route::post('login', 'LoginController@login')->**withoutMiddleware**(['auth']); for this function and do whatever you wants to do
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dharman |
