pawangspandey / accesscontrol-middleware

14 stars 6 forks source link

Comparison of operands #3

Closed BlueAccords closed 6 years ago

BlueAccords commented 6 years ago

For this line

        if (firstOperand === secondOperand) {

It will not compare values correctly if one is a string (like req.params.id) and one is a number(like req.user.id).

Any ideas on the best way to fix this without any unwanted side effects? Maybe include another option to convert the resource to?

Like expectedType: 'number' will call Number() on firstOperand ?

pawangspandey commented 6 years ago

hey, @BlueAccords , Good Observation and Nice Suggestion. we could convert each operand into a mutual data type maybe into strings. this will solve the issue without passing extra option expectedType.

pawangspandey commented 6 years ago

@BlueAccords, Published 1.0.3 on NPM. Though I have written test case, Can you please try installing 1.0.3 and let me know if this solves your issue?.

BlueAccords commented 6 years ago

Yeah it seems to be working, thanks for the update! There's also another issue I need to solve but i'll make a separate issue for it.