mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
refactor(coderd/httpapi): remove database, dbauthz and rbac imports (#9481)
Ref: #9380
This commit is contained in:
committed by
GitHub
parent
d2115941b7
commit
6fc1f5276d
@ -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 {
|
||||
|
Reference in New Issue
Block a user