Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
donch1989 committed Dec 6, 2023
1 parent 373c59c commit 739158b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion integration-test/grpc-public-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export function CheckPublicPatchAuthenticatedUser(header) {
user: userUpdate,
update_mask: "role"
}, header), {
'core.mgmt.v1beta.MgmtPublicService/PatchAuthenticatedUser nonExistRole StatusInvalidArgument': (r) => {console.log(r); return r && r.status == grpc.StatusInvalidArgument},
'core.mgmt.v1beta.MgmtPublicService/PatchAuthenticatedUser nonExistRole StatusInvalidArgument': (r) => r.status == grpc.StatusInvalidArgument,
});

});
Expand Down
15 changes: 15 additions & 0 deletions pkg/handler/publichandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ func (h *PublicHandler) GetUser(ctx context.Context, req *mgmtPB.GetUserRequest)
return nil, err
}
userID := strings.Split(req.Name, "/")[1]
if userID == "me" && ctxUserID == "" {
return nil, service.ErrUnauthenticated
}
if userID == "me" {
userID = ctxUserID
}
Expand Down Expand Up @@ -1252,6 +1255,9 @@ func (h *PublicHandler) ListUserMemberships(ctx context.Context, req *mgmtPB.Lis
return nil, err
}
userID := strings.Split(req.Parent, "/")[1]
if userID == "me" && ctxUserID == "" {
return nil, service.ErrUnauthenticated
}
if userID == "me" {
userID = ctxUserID
}
Expand Down Expand Up @@ -1294,6 +1300,9 @@ func (h *PublicHandler) GetUserMembership(ctx context.Context, req *mgmtPB.GetUs
span.SetStatus(1, err.Error())
return nil, err
}
if userID == "me" && ctxUserID == "" {
return nil, service.ErrUnauthenticated
}
if userID == "me" {
userID = ctxUserID
}
Expand Down Expand Up @@ -1337,6 +1346,9 @@ func (h *PublicHandler) UpdateUserMembership(ctx context.Context, req *mgmtPB.Up
span.SetStatus(1, err.Error())
return nil, err
}
if userID == "me" && ctxUserID == "" {
return nil, service.ErrUnauthenticated
}
if userID == "me" {
userID = ctxUserID
}
Expand Down Expand Up @@ -1388,6 +1400,9 @@ func (h *PublicHandler) DeleteUserMembership(ctx context.Context, req *mgmtPB.De
span.SetStatus(1, err.Error())
return nil, err
}
if userID == "me" && ctxUserID == "" {
return nil, service.ErrUnauthenticated
}
if userID == "me" {
userID = ctxUserID
}
Expand Down

0 comments on commit 739158b

Please sign in to comment.