[866092] Refactored SSO client-side code a bit

Ref: https://bugzilla.mozilla.org/show_bug.cgi?id=866092