Context:
A common access check or modifier is to use something like:
require(boolMapping[msg.sender] == true);
to ensure the caller is approved to use a function.
Since mapping (address => uint256) uintMapping
defaults all unset values to 0
, my question is:
Question: Is it safe to use this:
require(uintMapping[msg.sender] > 0, "not authorised");
instead of this:
require(boolMapping[msg.sender] == true, "not authorised");
to restrict use of a function, assuming pre-authorised accounts are set with values greater than zero?
(This would help condense the amount of storage required on a contract where users already have associated non-zero numbers, as we wouldn't need to use a struct or a second auth mapping).
Thank you!