|
|
|
@ -225,7 +225,8 @@ func (s *APIV1Service) UpdateMemo(ctx context.Context, request *v1pb.UpdateMemoR
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, status.Errorf(codes.Internal, "failed to get current user")
|
|
|
|
|
}
|
|
|
|
|
if memo.CreatorID != user.ID {
|
|
|
|
|
// Only the creator or admin can update the memo.
|
|
|
|
|
if memo.CreatorID != user.ID && !isSuperUser(user) {
|
|
|
|
|
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -336,7 +337,8 @@ func (s *APIV1Service) DeleteMemo(ctx context.Context, request *v1pb.DeleteMemoR
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, status.Errorf(codes.Internal, "failed to get current user")
|
|
|
|
|
}
|
|
|
|
|
if memo.CreatorID != user.ID {
|
|
|
|
|
// Only the creator or admin can update the memo.
|
|
|
|
|
if memo.CreatorID != user.ID && !isSuperUser(user) {
|
|
|
|
|
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1167,3 +1169,7 @@ func substring(s string, length int) string {
|
|
|
|
|
|
|
|
|
|
return s[:byteIndex]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func isSuperUser(user *store.User) bool {
|
|
|
|
|
return user.Role == store.RoleAdmin || user.Role == store.RoleHost
|
|
|
|
|
}
|
|
|
|
|