Skip to content

Commit

Permalink
chore: remove duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
davidby-influx committed Dec 22, 2023
1 parent cabccc1 commit 3b9b9e5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions authorization/storage_authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,13 @@ func (s *Store) GetAuthorizationByID(ctx context.Context, tx kv.Tx, id platform.
return a, nil
}

func (s *Store) GetAuthorizationByToken(ctx context.Context, tx kv.Tx, token string) (*influxdb.Authorization, error) {
func (s *Store) GetAuthorizationByToken(ctx context.Context, tx kv.Tx, token string) (auth *influxdb.Authorization, retErr error) {
defer func() {
retErr = errors.ErrInternalServiceError(retErr, errors.WithErrorOp(influxdb.OpFindAuthorizationByToken))
}()
idx, err := authIndexBucket(tx)
if err != nil {
return nil, errors.ErrInternalServiceError(err, errors.WithErrorOp(influxdb.OpFindAuthorizationByToken))
return nil, err
}

// use the token to look up the authorization's ID
Expand All @@ -153,7 +156,6 @@ func (s *Store) GetAuthorizationByToken(ctx context.Context, tx kv.Tx, token str
return nil, &errors.Error{
Code: errors.ENotFound,
Msg: "authorization not found",
Op: influxdb.OpFindAuthorizationByToken,
}
}

Expand All @@ -162,11 +164,9 @@ func (s *Store) GetAuthorizationByToken(ctx context.Context, tx kv.Tx, token str
return nil, &errors.Error{
Code: errors.EInvalid,
Err: err,
Op: influxdb.OpFindAuthorizationByToken,
}
}

// Do not use deferred error processing to avoid overwriting error opCode here
return s.GetAuthorizationByID(ctx, tx, id)
}

Expand Down

0 comments on commit 3b9b9e5

Please sign in to comment.