From 0e638fc1cc3d9360a336802834cf3e8292944fe7 Mon Sep 17 00:00:00 2001 From: Roman Perekhod Date: Mon, 20 Nov 2023 08:17:17 +0100 Subject: [PATCH] fix 500 when open public link from deleted user --- changelog/unreleased/fix-status-code.md | 6 ++++++ pkg/auth/manager/publicshares/publicshares.go | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/fix-status-code.md diff --git a/changelog/unreleased/fix-status-code.md b/changelog/unreleased/fix-status-code.md new file mode 100644 index 0000000000..e9ace3972b --- /dev/null +++ b/changelog/unreleased/fix-status-code.md @@ -0,0 +1,6 @@ +Bugfix: Fix 500 when open public link + +We fixed a bug that caused nil pointer and Error 500 when open a public link from a deleted user + +https://github.com/cs3org/reva/pull/4351 +https://github.com/owncloud/ocis/issues/7740 diff --git a/pkg/auth/manager/publicshares/publicshares.go b/pkg/auth/manager/publicshares/publicshares.go index 3ee7edbad9..d7a513362d 100644 --- a/pkg/auth/manager/publicshares/publicshares.go +++ b/pkg/auth/manager/publicshares/publicshares.go @@ -135,8 +135,15 @@ func (m *manager) Authenticate(ctx context.Context, token, secret string) (*user getUserResponse, err := gwConn.GetUser(ctx, &userprovider.GetUserRequest{ UserId: publicShareResponse.GetShare().GetCreator(), }) - if err != nil { + switch { + case err != nil: return nil, nil, err + case getUserResponse.GetStatus().GetCode() == rpcv1beta1.Code_CODE_NOT_FOUND: + return nil, nil, errtypes.NotFound(getUserResponse.GetStatus().GetMessage()) + case getUserResponse.GetStatus().GetCode() == rpcv1beta1.Code_CODE_PERMISSION_DENIED: + return nil, nil, errtypes.InvalidCredentials(getUserResponse.GetStatus().GetMessage()) + case getUserResponse.GetStatus().GetCode() != rpcv1beta1.Code_CODE_OK: + return nil, nil, errtypes.InternalError(getUserResponse.GetStatus().GetMessage()) } owner = getUserResponse.GetUser() }