问题
I am struggling with something that I would have thought ServiceStack would do "out of the box"...
I have a ServiceStack API that allows authentication via credentials, basic, google OpenId and LinkedIn OAuth2.
Starting with empty UserAuth and UserAuthDetails table I have found that if I:
- start my app and use credentials to log in
- log out
- log in using Google OpenId auth
ServiceStack creates two separate UserAuth records rather than linking the Google UserAuthDetail with the Credential authenticated UserAuth. This is despite the two credentials showing the same email address in both records.
BUT... If I start from a blank database and repeat the steps using the LinkedIn OAuth2 I find that a single UserAuth record is created with a linked UserAuthDetails record. This is what I want the Google Auth to do.
Can anyone shed any light on why this is happening and what I must do to ensure the Google Auth doesn't create a new UserAuth if there is already one with a matching email address?
回答1:
ServiceStack merges User Auth details for the current authenticated user session. i.e. not on any matching value returned by the OpenId/OAuth providers.
If you log out, then you end the current users session and authenticating again will behave as if it were a new browser session.
来源:https://stackoverflow.com/questions/22492917/why-doesnt-servicestack-always-link-userauth-and-userauthdetails