mirror of
https://github.com/harness/drone.git
synced 2025-05-05 15:32:56 +00:00
feat: [CODE-2318]: Update error message in case of forbidden (#2780)
* feat: [CODE-2318]: update error logic to be translate in controller * Merge branch 'main' into akp/CODE-2318 * feat: [CODE-2318]: update error logic to be translate in controller * feat: [CODE-2318]: remove nested error handling * feat: [CODE-2318]: Update error message in case of forbidden
This commit is contained in:
parent
d21176e612
commit
fd848b1e15
@ -16,6 +16,7 @@ package principal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
apiauth "github.com/harness/gitness/app/api/auth"
|
||||
@ -41,7 +42,7 @@ func (c controller) List(
|
||||
)
|
||||
}
|
||||
|
||||
if err := apiauth.Check(
|
||||
err := apiauth.Check(
|
||||
ctx,
|
||||
c.authorizer,
|
||||
session,
|
||||
@ -50,7 +51,14 @@ func (c controller) List(
|
||||
Type: enum.ResourceTypeUser,
|
||||
},
|
||||
enum.PermissionUserView,
|
||||
); err != nil {
|
||||
)
|
||||
if errors.Is(err, apiauth.ErrNotAuthorized) {
|
||||
return nil, usererror.Forbidden(
|
||||
"You lack the permission to list users. " +
|
||||
"Please grant User view permission at the account level.",
|
||||
)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user