feat(server): add project sharing access control
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"img_infinite_canvas/internal/domain/design"
|
||||
authmodule "img_infinite_canvas/internal/modules/auth"
|
||||
sharingmodule "img_infinite_canvas/internal/modules/sharing"
|
||||
)
|
||||
|
||||
type CodeError struct {
|
||||
@@ -47,6 +48,18 @@ func Handle(ctx context.Context, err error) (int, any) {
|
||||
return http.StatusBadRequest, map[string]any{"error": err.Error(), "errorCode": "auth.human_verification_failed", "code": http.StatusBadRequest}
|
||||
case errors.Is(err, authmodule.ErrProviderNotReady):
|
||||
return http.StatusBadRequest, map[string]any{"error": err.Error(), "errorCode": "auth.provider_not_ready", "code": http.StatusBadRequest}
|
||||
case errors.Is(err, sharingmodule.ErrLoginRequired):
|
||||
return http.StatusUnauthorized, map[string]any{"error": err.Error(), "errorCode": "share.login_required", "code": http.StatusUnauthorized}
|
||||
case errors.Is(err, sharingmodule.ErrSelfInvite):
|
||||
return http.StatusConflict, map[string]any{"error": err.Error(), "errorCode": "share.self_invite", "code": http.StatusConflict}
|
||||
case errors.Is(err, sharingmodule.ErrMemberExists):
|
||||
return http.StatusConflict, map[string]any{"error": err.Error(), "errorCode": "share.member_exists", "code": http.StatusConflict}
|
||||
case errors.Is(err, sharingmodule.ErrForbidden):
|
||||
return http.StatusForbidden, map[string]any{"error": err.Error(), "errorCode": "share.forbidden", "code": http.StatusForbidden}
|
||||
case errors.Is(err, sharingmodule.ErrNotFound):
|
||||
return http.StatusNotFound, map[string]any{"error": sharingmodule.ErrNotFound.Error(), "errorCode": "share.not_found", "code": http.StatusNotFound}
|
||||
case errors.Is(err, sharingmodule.ErrInvalidInput):
|
||||
return http.StatusBadRequest, map[string]any{"error": err.Error(), "errorCode": "share.invalid_input", "code": http.StatusBadRequest}
|
||||
case errors.Is(err, context.Canceled):
|
||||
return http.StatusRequestTimeout, map[string]any{"error": "request canceled", "code": http.StatusRequestTimeout}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user