Skip to content

Commit

Permalink
redirect user to welcome / access level page on first visit #1
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost committed Sep 11, 2023
1 parent b3f26fd commit 9f28412
Show file tree
Hide file tree
Showing 8 changed files with 263 additions and 139 deletions.
55 changes: 55 additions & 0 deletions src/public/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@
$response->message = _('Could not init user info');
}

// On first visit, redirect user to the welcome page with access level question
else if (is_null($user->public))
{
header(
sprintf('Location: %s/welcome.php', WEBSITE_URL)
);
}

// Render icon
else
{
Expand Down Expand Up @@ -105,6 +113,14 @@
$response->message = _('Could not init user info');
}

// On first visit, redirect user to the welcome page with access level question
else if (is_null($user->public))
{
header(
sprintf('Location: %s/welcome.php', WEBSITE_URL)
);
}

// Magnet comment exists
else if (!$magnetComment = $db->getMagnetComment(isset($_GET['magnetCommentId']) && $_GET['magnetCommentId'] > 0 ? (int) $_GET['magnetCommentId'] : 0))
{
Expand Down Expand Up @@ -186,6 +202,14 @@
$response->message = _('Could not init user info');
}

// On first visit, redirect user to the welcome page with access level question
else if (is_null($user->public))
{
header(
sprintf('Location: %s/welcome.php', WEBSITE_URL)
);
}

// Magnet comment exists
else if (!$magnetComment = $db->getMagnetComment(isset($_GET['magnetCommentId']) && $_GET['magnetCommentId'] > 0 ? (int) $_GET['magnetCommentId'] : 0))
{
Expand Down Expand Up @@ -256,6 +280,14 @@
$response->message = _('Could not init user info');
}

// On first visit, redirect user to the welcome page with access level question
else if (is_null($user->public))
{
header(
sprintf('Location: %s/welcome.php', WEBSITE_URL)
);
}

// Magnet exists
else if (!$magnet = $db->getMagnet(isset($_GET['magnetId']) && $_GET['magnetId'] > 0 ? (int) $_GET['magnetId'] : 0))
{
Expand Down Expand Up @@ -342,6 +374,21 @@
$response->message = _('Could not init user session');
}

// Get user
else if (!$user = $db->getUser($userId))
{
$response->success = false;
$response->message = _('Could not init user info');
}

// On first visit, redirect user to the welcome page with access level question
else if (is_null($user->public))
{
header(
sprintf('Location: %s/welcome.php', WEBSITE_URL)
);
}

// Magnet exists
else if (!$magnet = $db->getMagnet(isset($_GET['magnetId']) && $_GET['magnetId'] > 0 ? (int) $_GET['magnetId'] : 0))
{
Expand Down Expand Up @@ -415,6 +462,14 @@
$response->message = _('Could not init user info');
}

// On first visit, redirect user to the welcome page with access level question
else if (is_null($user->public))
{
header(
sprintf('Location: %s/welcome.php', WEBSITE_URL)
);
}

// Validate link
if (empty($_GET['magnet']))
{
Expand Down
Loading

0 comments on commit 9f28412

Please sign in to comment.