Skip to content

Commit

Permalink
remove redundant checks
Browse files Browse the repository at this point in the history
  • Loading branch information
din-mukhammed committed Aug 26, 2023
1 parent 883a8bb commit feddd6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
5 changes: 0 additions & 5 deletions code/go/0chain.net/blobbercore/handler/file_command_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ func (cmd *UploadFileCommand) IsValidated(ctx context.Context, req *http.Request
return common.NewError("duplicate_file", msg)
}

if allocationObj.OwnerID != clientID &&
allocationObj.RepairerID != clientID {
return common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation")
}

_, thumbHeader, _ := req.FormFile(UploadThumbnailFile)
if thumbHeader != nil {
if thumbHeader.Size > MaxThumbnailSize {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,15 +430,19 @@ func (fsh *StorageHandler) CreateConnection(ctx context.Context, r *http.Request
clientID := ctx.Value(constants.ContextKeyClient).(string)
_ = ctx.Value(constants.ContextKeyClientKey).(string)

if clientID == "" {
return nil, common.NewError("invalid_operation", "Invalid client")
}

if allocationObj.OwnerID != clientID && allocationObj.RepairerID != clientID {
return nil, common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation")
}

valid, err := verifySignatureFromRequest(allocationTx, r.Header.Get(common.ClientSignatureHeader), allocationObj.OwnerPublicKey)
if !valid || err != nil {
return nil, common.NewError("invalid_signature", "Invalid signature")
}

if clientID == "" {
return nil, common.NewError("invalid_operation", "Invalid client")
}

connectionID := r.FormValue("connection_id")
if connectionID == "" {
return nil, common.NewError("invalid_parameters", "Invalid connection id passed")
Expand Down Expand Up @@ -1195,10 +1199,6 @@ func (fsh *StorageHandler) WriteFile(ctx context.Context, r *http.Request) (*blo
return nil, common.NewError("invalid_signature", "Invalid signature")
}

if clientID == "" {
return nil, common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation")
}

connectionID, ok := common.GetField(r, "connection_id")
if !ok {
return nil, common.NewError("invalid_parameters", "Invalid connection id passed")
Expand Down

0 comments on commit feddd6f

Please sign in to comment.