servicestackservicestack-auth

How to remove only one provider from UserOAuthProviders


To associate social providers to the user account, we can simply use api/auth/facebook and I could also find that using auth/logout would logout the user...

in the database, 2 profiles are still there, so logout is a simple way to kill the auth session... but how can I unlink them?

enter image description here


NOTE: I got here when I added /Friends/Index.cshtml View (without a controller) as the social logins started to work "out-of-the-blue"... I did not find anything in the docs regarding this, might be a good idea to have such important note :)

this is done with oauth.<provider>.CallbackUrl on web.config!


Solution

  • There's not an explicit API for deleting UserAuth records, but you can just use OrmLite and the UserAuth POCO's to delete them as you wish, e.g you can remove twitter provider record with:

    Db.Delete<UserOAuthProviders>(q => 
        q.UserAuthId == 5 && q.Provider == "twitter");
    

    The default behavior of the AuthProviders is that when logging into existing AuthProviders when you're already authenticated will link them to the same account. To have each login create separate accounts (i.e. new UserAuth entry) you want to /logout first.