refactor(coderd/httpapi): remove database, dbauthz and rbac imports (#9481)

Ref: #9380
This commit is contained in:
Mathias Fredriksson
2023-09-04 19:39:14 +03:00
committed by GitHub
parent d2115941b7
commit 6fc1f5276d
5 changed files with 40 additions and 7 deletions

View File

@ -17,6 +17,7 @@ import (
"cdr.dev/slog"
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbtime"
"github.com/coder/coder/v2/coderd/httpapi/httpapiconstraints"
"github.com/coder/coder/v2/coderd/rbac"
"github.com/coder/coder/v2/coderd/util/slice"
)
@ -36,10 +37,18 @@ type NotAuthorizedError struct {
Err error
}
// Ensure we implement the IsUnauthorized interface.
var _ httpapiconstraints.IsUnauthorizedError = (*NotAuthorizedError)(nil)
func (e NotAuthorizedError) Error() string {
return fmt.Sprintf("unauthorized: %s", e.Err.Error())
}
// IsUnauthorized implements the IsUnauthorized interface.
func (NotAuthorizedError) IsUnauthorized() bool {
return true
}
// Unwrap will always unwrap to a sql.ErrNoRows so the API returns a 404.
// So 'errors.Is(err, sql.ErrNoRows)' will always be true.
func (e NotAuthorizedError) Unwrap() error {