Skip to content
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

UTCT-57: A better 403 error with more info for those with no role. #58

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions user/plugins/auth-mgr-plus/403-error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div class="container-fluid h-100">
<div class="row justify-content-center align-items-center h-100">
<div class="col-12 col-lg-10 col-xl-8 col-xxl-5 mt-5">
<div class="card border-0 mt-5">
<div class="text-center">
<img src="https://go.utc.edu/frontend/assets/svg/utc-wordmark-reverse.svg" alt="UTC Logo" width="300px" style="margin-top:-4rem;">
</div>
<div class="card-body px-md-5">
<h5 class="card-title">Access Denied</h5>
<h6 class="card-subtitle mb-2 text-muted">go.UTC.edu is the UTC URL Shortener</h6>
<p class="card-text">Your account does not have access to this app, other than to follow links.</p>
<a href="https://go.utc.edu/home" class="card-link">go to www.UTC.edu</a>
</div>
</div>
<div class="d-flex flex-column flex-md-row align-items-center my-3">
<span class="text-white fw-light">© <?php echo date("Y"); ?> go.UTC.edu</span>
<div class="ms-3">
<a class="bold-link me-3 text-white text-decoration-none" href="https://github.com/UTCWeb/utctiny#utctiny"><span>About</span></a>
<a class="bold-link me-3 text-white text-decoration-none" href="https://www.utc.edu/about/privacy"><span>Privacy</span></a>
</div>
</div>
</div>
</div>
</div>
7 changes: 5 additions & 2 deletions user/plugins/auth-mgr-plus/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,11 @@ function amp_require_capability( $capability ) {
if ( !amp_have_capability( $capability ) ) {
// If the user can't view admin interface, return a plain error.
if ( !amp_have_capability( ampCap::ShowAdmin ) ) {
// header("HTTP/1.0 403 Forbidden");
die('Require permissions to show admin interface.');
header("HTTP/1.0 403 Forbidden");
$errorpage = file_get_contents('user/plugins/auth-mgr-plus/403-error.html');
yourls_status_header( 403 );
echo $errorpage;
die();
}
// Otherwise, render errors in admin interface
yourls_redirect( yourls_admin_url( '?access=denied' ), 302 );
Expand Down