-
Notifications
You must be signed in to change notification settings - Fork 13
refactor session #570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
simonLeary42
wants to merge
9
commits into
main
Choose a base branch
from
refactor-session
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
refactor session #570
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8986b75
refactor session
simonLeary42 0fe8720
remove admin check
simonLeary42 2bb9811
set session keys properly
simonLeary42 6b5acd3
isPI
simonLeary42 bdad2d1
getFlag
simonLeary42 42678ca
typo
simonLeary42 0d9e21c
check for viewUser
simonLeary42 9c68143
refactor
simonLeary42 857d70b
move comment
simonLeary42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,12 +5,13 @@ | |
| if ($_SERVER["REQUEST_METHOD"] == "POST") { | ||
| // another page should have already validated and we can't validate the same token twice | ||
| // UnityHTTPD::validatePostCSRFToken(); | ||
| if ( | ||
| ($_SESSION["is_admin"] ?? false) == true | ||
| && ($_POST["form_type"] ?? null) == "clearView" | ||
| ) { | ||
| unset($_SESSION["viewUser"]); | ||
| UnityHTTPD::redirect(getURL("admin/user-mgmt.php")); | ||
| if (($_POST["form_type"] ?? null) == "clearView") { | ||
| if (isset($_SESSION["viewUser"])) { | ||
| unset($_SESSION["viewUser"]); | ||
|
simonLeary42 marked this conversation as resolved.
|
||
| UnityHTTPD::redirect(getURL("admin/user-mgmt.php")); | ||
| } else { | ||
| throw new Exception('Cannot clearView because $_SESSION["viewUser"] is not set!'); | ||
| } | ||
| } | ||
| // Webroot files need to handle their own POSTs before loading the header | ||
| // so that they can do UnityHTTPD::badRequest before anything else has been printed. | ||
|
|
@@ -21,13 +22,8 @@ | |
| UnityHTTPD::redirect(); | ||
| } | ||
|
|
||
| if (isset($SSO)) { | ||
| if ( | ||
| !$_SESSION["user_exists"] | ||
| && !str_ends_with($_SERVER['PHP_SELF'], "/panel/new_account.php") | ||
| ) { | ||
| UnityHTTPD::redirect(getURL("panel/new_account.php")); | ||
| } | ||
| if (isset($USER) && !$USER->exists() && !str_ends_with($_SERVER['PHP_SELF'], "/new_account.php")) { | ||
| UnityHTTPD::redirect(getURL("panel/new_account.php")); | ||
| } | ||
|
|
||
| ?> | ||
|
|
@@ -91,7 +87,6 @@ | |
|
|
||
| <nav class="mainNav"> | ||
| <?php | ||
| // Public Items - Always Visible | ||
| echo getHyperlink("Home", "index.php") . "\n"; | ||
|
|
||
| $num_additional_items = count(CONFIG["menuitems"]["labels"]); | ||
|
|
@@ -100,30 +95,23 @@ | |
| CONFIG["menuitems"]["labels"][$i] . "</a>\n"; | ||
| } | ||
|
|
||
| if (isset($_SESSION["user_exists"]) && $_SESSION["user_exists"]) { | ||
| if ($_SESSION["navbar_show_logged_in_user_pages"] ?? false) { | ||
| echo "<hr class='navHR'>\n"; | ||
| // Menu Items for Present Users | ||
| echo getHyperlink("Account Settings", "panel/account.php") . "\n"; | ||
| echo getHyperlink("My PIs", "panel/groups.php") . "\n"; | ||
|
|
||
| if (isset($_SESSION["is_pi"]) && $_SESSION["is_pi"]) { | ||
| // PI only pages | ||
| if ($_SESSION["navbar_show_pi_pages"] ?? false) { | ||
| echo getHyperlink("My Users", "panel/pi.php") . "\n"; | ||
| } | ||
|
|
||
| // additional branding items | ||
| $num_additional_items = count(CONFIG["menuitems_secure"]["labels"]); | ||
| for ($i = 0; $i < $num_additional_items; $i++) { | ||
| echo "<a target='_blank' href='" . CONFIG["menuitems_secure"]["links"][$i] . "'>" . | ||
| CONFIG["menuitems_secure"]["labels"][$i] . "</a>\n"; | ||
| } | ||
|
|
||
| // admin pages | ||
| if ( | ||
| isset($_SESSION["is_admin"]) && $_SESSION["is_admin"] && !isset($_SESSION["viewUser"]) | ||
| ) { | ||
| if ($_SESSION["navbar_show_admin_pages"] ?? false) { | ||
| echo "<hr class='navHR'>\n"; | ||
| // Admin only pages | ||
| echo getHyperlink("User Management", "admin/user-mgmt.php") . "\n"; | ||
| echo getHyperlink("PI Management", "admin/pi-mgmt.php") . "\n"; | ||
| } | ||
|
|
@@ -177,11 +165,7 @@ | |
| ); | ||
| } | ||
| echo "</div>"; | ||
| if ( | ||
| isset($_SESSION["is_admin"]) | ||
| && $_SESSION["is_admin"] | ||
| && isset($_SESSION["viewUser"]) | ||
| ) { | ||
| if (isset($_SESSION["viewUser"])) { | ||
|
Comment on lines
167
to
+168
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Authorization not needed here because authorization is already required to set |
||
| $viewUser = $_SESSION["viewUser"]; | ||
| $CSRFTokenHiddenFormInput = UnityHTTPD::getCSRFTokenHiddenFormInput(); | ||
| echo " | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.