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

Display API errors on AngularJS pages #2378

Merged
merged 2 commits into from
Aug 8, 2024
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
3 changes: 2 additions & 1 deletion app/cdash/include/api_common.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ function can_access_project($projectid): bool

$logged_in = Auth::check();
if ($logged_in) {
abort(403, 'You do not have permission to access this page.');
Gate::authorize('view-project', $project);
return false;
} else {
throw new AuthenticationException();
}
Expand Down
5 changes: 5 additions & 0 deletions resources/views/cdash.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
ng-if="!loading"
@endif
>

@if(isset($angular) && $angular === true)
<div ng-if="cdash.error">@{{cdash.error}}</div>
@endif

@hasSection('main_content')
@yield('main_content')
@elseif(isset($xsl) && $xsl === true)
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/ProjectPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function testProjectPermissions(): void
// Verify that she cannot access PrivateProject2.
$_GET['project'] = $this->private_project2->Name;
$response = $this->actingAs($this->normal_user)->get('/api/v1/index.php');
$response->assertJson(['error' => 'You do not have permission to access this page.']);
$response->assertJson(['error' => 'You do not have access to the requested project or the requested project does not exist.']);

// Verify that viewProjects.php lists public, protected, and private1, but not private2.
$_GET['project'] = '';
Expand Down