Kebin Maharjan - 192 - Jan 12, 2015

Hi there,
Anyone knows how to tell if a user was authenticated via custom provider or fb etc inside of CustomUserSession: AuthUserSession?


Kebin Maharjan:

Looks like I can check IAuthTokes to see if it is null and get a provider name from there?

Darren Reid:

You can check the provider during the OnAuthenticated override of the AuthUserSession. 

An example from the TechStacks demo shows it working with Twitter and GitHub auth providers, but the same could be used with Facebook.

More info on session events here

Hope that helps.

Kebin Maharjan:

Thanks Darren! Checking provider won’t actually work because it will list all the auth providers that a user has created. i.e if I have fb, github, twitter associated, provider with list all of those even if I logged in via one of those. Looks like tokens will actually give us which provider a user used to authenticate. 
Thanks for the pointer!