Skip to content

Commit

Permalink
update error copy
Browse files Browse the repository at this point in the history
  • Loading branch information
SupaJoon committed Sep 30, 2024
1 parent 64f90af commit 3656959
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions graphql/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ func New(apiURL string) Config {
forbiddenHosts = append(forbiddenHosts, h.Id)
}
}
if len(forbiddenHosts) > 0 {
if len(forbiddenHosts) == 1 {
return nil, Forbidden.Send(ctx, fmt.Sprintf("user '%s' does not have permission to access host '%v'", user.Username(), forbiddenHosts[0]))
} else if len(forbiddenHosts) > 1 {
hostsString := strings.Join(forbiddenHosts, ", ")
return nil, Forbidden.Send(ctx, fmt.Sprintf("user '%s' does not have permission to access the hosts: '%v'", user.Username(), hostsString))
return nil, Forbidden.Send(ctx, fmt.Sprintf("user '%s' does not have permission to access hosts: '%v'", user.Username(), hostsString))
}

return next(ctx)
Expand Down
2 changes: 1 addition & 1 deletion graphql/tests/mutation/reprovisionToNew/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"data": null,
"errors": [
{
"message": "user 'testuser' does not have permission to access the host 'i-0d0ae8b83366d22be'",
"message": "user 'testuser' does not have permission to access host 'i-0d0ae8b83366d22be'",
"path": [
"reprovisionToNew",
"hostIds"
Expand Down
2 changes: 1 addition & 1 deletion graphql/tests/mutation/restartJasper/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"data": null,
"errors": [
{
"message": "user 'testuser' does not have permission to access the host 'i-0d0ae8b83366d22be'",
"message": "user 'testuser' does not have permission to access host 'i-0d0ae8b83366d22be'",
"path": [
"restartJasper",
"hostIds"
Expand Down
2 changes: 1 addition & 1 deletion graphql/tests/mutation/updateHostStatus/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"data": null,
"errors": [
{
"message": "user 'testuser' does not have permission to access the host 'i-0d0ae8b83366d22be'",
"message": "user 'testuser' does not have permission to access host 'i-0d0ae8b83366d22be'",
"path": [
"updateHostStatus",
"hostIds"
Expand Down
4 changes: 2 additions & 2 deletions graphql/tests/mutation/updateSpawnHostStatus/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"data": null,
"errors": [
{
"message": "user 'testuser' does not have permission to access the host 'i-085085e236d598a60'",
"message": "user 'testuser' does not have permission to access host 'i-085085e236d598a60'",
"path": [
"updateSpawnHostStatus",
"updateSpawnHostStatusInput",
Expand All @@ -25,7 +25,7 @@
"data": null,
"errors": [
{
"message": "user 'testuser' does not have permission to access the host 'i-085085e236d598a60'",
"message": "user 'testuser' does not have permission to access host 'i-085085e236d598a60'",
"path": [
"updateSpawnHostStatus",
"updateSpawnHostStatusInput",
Expand Down
2 changes: 1 addition & 1 deletion graphql/tests/query/hostsForbidden/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"data": null,
"errors": [
{
"message": "user 'testuser' does not have permission to access one or more hosts.",
"message": "user 'testuser' does not have permission to access one or more hosts",
"path": [
"hosts"
],
Expand Down

0 comments on commit 3656959

Please sign in to comment.