首页 > 解决方案 > Fusionauth user with two possibillity to login

问题描述

Let's assume I have several types of users in one application in fusionauth. One of them with role A can register/login by fusionauth standard login mechanism. Another one with role 'B' can login via facebook. The user with role B receives the role A. Now he has both roles. Is it possible to somehow allow him login both ways ? Is it possible to add a registration to this user so he can set a password a login the standard way ?

标签: facebookfusionauth

解决方案


If I understand your use case correctly, this is definitely possible in FusionAuth. Here's a diagram that illustrates the relationships in FusionAuth:

User <--- UserRegistration ---> Application <--- ApplicationRole
                 |                                      ^
                 \--------------------------------------/

Let's say your user is joe@example.com. Joe can login through Facebook initially and FusionAuth can be configured to create a User object for him. This is called "Create Registration" and is part of Identity Provider configuration.

Later, if Joe clicks the "Forgot Password" link, FusionAuth will send him an email and he can then set a new password.

This means that at anytime, Joe can now login using Facebook or using his email address and password.

In addition, Joe can have multiple UserRegistration objects. Let's say that you have two Applications, one called A and one called B. When Joe logged in using Facebook the first time, if he was signing into Application A, FusionAuth would have created a UserRegistration object for him for Application A and this UserRegistration would be granted all of the default ApplicationRoles for Application A.

Later, if Joe did the "Forgot Password" workflow and then logged into Application B, FusionAuth can be configured to create a UserRegistration object for Joe in Application B and this would have also granted Joe all of the default roles for Application B. This configuration is under the Application on the Registration tab. If you enable registrations for an Application then FusionAuth will create UserRegistration objects for Users that exist but don't have a UserRegistration for the Application they are logging into.

Lastly, you can grant Joe any additional roles for any Application using the /api/user/registration API (https://fusionauth.io/docs/v1/tech/apis/registrations).


推荐阅读