schibsted / account-sdk-browser

Schibsted Account SDK for browsers
https://schibsted.github.io/account-sdk-browser/
MIT License
16 stars 11 forks source link

Inconsistent (assymetric) API (Identity.login vs Identity.hasSession) #72

Open vasklund opened 6 years ago

vasklund commented 6 years ago

I'm creating this as a bug / documentation issue, but I'm making some assumptions which might not be correct. We discovered the issue while upgrading to this library for www.svd.se.

Inconsistency

Example of why this is confusing

When implementing and testing Identity.login we opted to call the method with the redirectUri argument. It worked. However, when testing Identity.hasSession the auto-login feature didn't work. After debugging for a while we realized it works if we set redirectUri in the constructor instead (new Identity). But now there's no need to also call Identity.login with the redirectUri argument.

It would have been better if the documentation either told us we have to call the constructor with redirectUri (not optional) OR if Identity.hasSession also accepted a redirectUri argument (with documentation), so the API is "symmetrical" and we know it's needed for that method to work.