4 ms·
What was bad about it? Did they just do: bool hasAccess = HasAccess(token); private bool HasAccess = token: Jwt => { return IsLoggedIn(token) && I
by throw1234651234 3y ago
What was bad about it? Did they just do:
bool hasAccess = HasAccess(token);
private bool HasAccess = token: Jwt => {
return IsLoggedIn(token)
&& IsActive(token)
&& HasRbacPermission(token);
}
If so, what's wrong with that? It moves the complexity of HasAccess out of whatever is checking for access, before presumably doing other things.
* I have each check on its own line, don't want to reformat message to take up space here.
- Ensorceled 3y agoIt was fairly long series of checks, some complicated, and they mixed up an or and not case when merging them into the single if.
- throw1234651234 3y agoAh, I see now. I think it's a very common mistake. People also mess up negation when they refactor things like these. So your original was if(!loggedIn) return Unauthorized; if(isTokenExpired) return Unauthorized; etc? I think being that explicit about it works pretty well sometimes.