You need to use a different browser. Not tab.
browser tabs shared session data causes loading wrong data
We realized we have a bug loading data in a secondary tab while project data in the first tab is still open. The second project then loads data from the project in the first tab. This is because we use session data and that is shared by both browser tabs.
This is the code
public static function saveProjectFromJSON($json)
{
$project = json_decode($json);
$currentProject = self::getProjectFromSession();
....
return $currentProject->save();
}
and it uses getProjectFromSession:
public static function getProjectFromSession()
{
$projectId = session('currentproject');
return self::find($projectId);
}
I understood PHP and sessions works this way.
So we could use something like
public static function saveProjectFromJSON($json)
{
$attrs = json_decode($json);
$project = self::find($attrs->id);
$project->json = json_encode($attrs);
return $project->save();
}
and replace getProjectFromSession everywhere and use database data. But then we got into issues with urls loading project id and allowing manual change of id to check for other projects not even under the user's id due to code like
// Get Pages
axios.get(`/editor/get-pages?project=${PROJECT_ID}`)
.then(res => {
this.$store.dispatch('editor/setPages', res.data.data)
})
.catch(() => {});
NB const PROJECT_ID = {{ $project->id }}
no longer using the auth check in the route
...
Route::prefix('editor')->middleware('auth', 'subcheck')->group(function () {
...
Route::get('get-pages', [Editor\ProjectController::class, 'getPages']);
...
So how can I disallow loading data form another project in a new tab using a different project AND disallow access via a url likehttps://site/editor?project=22 just by changing the number? The session check causes issues for loading data when using multiple tabs, but now without it I am giving access to other projects by other users..
Please or to participate in this conversation.