Refactor initiate sso logic. Fix prevent password bug