-
Notifications
You must be signed in to change notification settings - Fork 77
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
Display API errors on AngularJS pages #2378
Display API errors on AngularJS pages #2378
Conversation
da6ffcd
to
2dd4a8f
Compare
app/cdash/include/api_common.php
Outdated
@@ -63,7 +63,7 @@ function can_access_project($projectid): bool | |||
|
|||
$logged_in = Auth::check(); | |||
if ($logged_in) { | |||
abort(403, 'You do not have permission to access this page.'); | |||
abort(404, 'Project not found.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this entire function could be replaced with the following:
function can_access_project($projectid): bool
{
Gate::authorize('view-project', $project);
return true;
}
Gate::authorize
will automatically handle throwing the right type of error (either 401 or 403 depending on login status).
This function is on my shortlist of functions to refactor eventually but doing this would be a decent immediate solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unconditionally using Gate::authorize
got rid of the requirelogin:1
redirect logic we have. But I do like using this function rather than abort()
for consistent error messaging.
2dd4a8f
to
ba44f3b
Compare
No description provided.