简体   繁体   中英

ASP.NET Core Identity: Multiple providers for the same account

I've been trying to wrap my head around the new ASP.NET Core Identity framework.

I want to be able to allow customers to sign-in using external providers so I do not have to worry about password storage. That works if I use the default provider: .AddDefaultIdentity<EntityUser>() , along with .AddAuthentication (with AddFacebook , AddGoogle , AddMicrosoftAccount ).

Some people have a Google account and a Facebook account. I would like to allow users to login to their account, and then add additional providers to the same user (so long as the e-mails match).

The Identity Framework portion of AspNetCore seems to tightly control everything. I know how to override the views, but not how to override control-flow. How can I dip my own logic into its processes to coerce login, registration? I would also like to forward a user to the external providers when the user is already logged in .

All I need is a direction, they've separated concerns so much with the new AspNetCore that it's akin to an onion. This makes it difficult to know where what you want is. I don't even know what I don't know to get started.

It already works the way you want, users can add any providers you've configured from the page at ~/Identity/Account/Manage/ExternalLogins

You can see the source code of the ExternalLogins razor page has logic which will show options for the user to add social auth to their existing account.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM