From 60fc5d9170d70721d7baa446969b3ca6e4d37d9d Mon Sep 17 00:00:00 2001 From: gr-dv Date: Mon, 10 Apr 2023 14:12:24 +0300 Subject: [PATCH] MSP-1658 /user/get_profile returning 401 for blocked users --- controller/user.go | 2 ++ service/user.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/controller/user.go b/controller/user.go index 066fada..82ec76f 100644 --- a/controller/user.go +++ b/controller/user.go @@ -58,6 +58,8 @@ func (u User) GetProfile(ctx context.Context, authData grpc.AuthData) (*domain.A profile, err := u.userService.GetProfileById(ctx, int64(adminId)) switch { + case errors.Is(err, domain.ErrUnauthenticated): + return nil, status.Error(codes.Unauthenticated, "user is blocked") case errors.Is(err, domain.ErrNotFound): return nil, status.Error(codes.NotFound, "user not found") case err != nil: diff --git a/service/user.go b/service/user.go index 683abb7..df8cec2 100644 --- a/service/user.go +++ b/service/user.go @@ -52,7 +52,7 @@ func (u User) GetProfileById(ctx context.Context, userId int64) (*domain.AdminUs return nil, errors.WithMessagef(err, "get user by id: %d", userId) } if user.Blocked { - return nil, errors.Errorf("user is blocked") + return nil, errors.WithMessagef(domain.ErrUnauthenticated, "user '%d' is blocked", user.Id) } role, err := u.userRoleRepo.GetRoleById(ctx, user.RoleId)