- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Plot twist - Paulette really works for TheDailyWTF and this line is in the login code section for this site's comment section. That is why it only works sometimes and people resort to posting as a guest and getting held for moderation.
Admin
maybe both functions have side effects and both need to be called to initialize the authentication providers
Admin
The fact they're passing String.Empty into both is key. Tim's idea has merit, but why structure the calls as an if statement rather than as two discarding method calls?
Assuming this isn't just pure stupidity or an artifact of some long-lost refactoring or maintenance change ...
Passing String.Empty into something that does a table lookup on that input has a few sorts of reasonable results. Return a deliberate default, return an accidental default (e.g. first or last in list), return null, or throw an exception.
My bet is the method returns a default and under some configuration circumstances those defaults are the same. In which case the rest of the code we don't see does ???.
Another horrid possibility is this is a sort of a version check. In the browser wars we learned to check for actual capabilities, not sniff the browser version and reason from than. Perhaps this dev absorbed that lesson a little too well and is sniffing for something that changed behavior between two long-ago versions.
Admin
My bet is also on side effects; specifically, I am wondering what the function does when an external provider is not available for some reason, due to networking issues, etc. I'm guessing that it might return an internal provider when the external one is not available and this line basically is an ad hoc "Is the external provider unavailable" check.
Admin
I stopped reading after wrapping authentication because I always don't read stories that start with cleaning a loaded gun.
Addendum 2023-04-19 10:33: And just right now I saw this popping up for my twitter subscriptions: https://twitter.com/dotnet/status/1648691927515029509
Irony? Nah. Just Darwin lol
Admin
*led
Admin
That makes a lot of sense. The empty string apparently makes sense to the provider, probably means do nothing. If external authentication is unavailable you get back this same internal one. Since it's actually looking it up in a table it's the same result in both cases. This really is:
bool IsExternalAuthenticaionUnavailable()
Admin
I thought it may have been some debugging code, checking that the method was doing what it said it was, and was accidentally left in.