-
Notifications
You must be signed in to change notification settings - Fork 366
logic for account merge suggestion #21
Comments
Merging is detected if a person is currently logged in with Account A and logs in with Account B without signing out of Account A before. So the merging actually does not happen by email address (which would be dangerous as for example not all OpenID providers will guarantee the validity of the email address), but by the actual authentication user. What exactly happens at the time of merging can be controlled from within the UserService - there is a method |
If you want to prevent users from creating multiple accounts that have the email address, you might want to do that in the If you are using OpenID providers, you can only trust them for the authentication part as well - not necessarily for the delivered user information, as anybody might just set up their own OpenID provider. |
Joscha - Thanks for the pointer on how to force multiple accounts to be the same with the same email address. I followed it and augmented the code as follows. Please let me know if I'm doing it correctly. Thanks in advance. In User.java:
public static User findByEmailIdentity(final EmailIdentity identity) {
return User.findByEmail(identity.getEmail());
}
In MyUserServicePlugin.java:
@Override
public Object save(final AuthUser authUser) {
final boolean isLinked = User.existsByAuthUserIdentity(authUser);
if (!isLinked) {
if (authUser instanceof EmailIdentity) {
EmailIdentity emailAuthUserIdentity = (EmailIdentity) authUser;
User user = User.findByEmailIdentity(emailAuthUserIdentity);
if (user != null) {
return user;
}
}
return User.create(authUser).id;
} else {
// we have this user already, so return null
return null;
}
}
In MyUsernamePasswordAuthProvider.java:
|
Looks fine, yes - in your last section in |
what is the code for figuring out if two accounts need to be merged?
is it based off email address?
The text was updated successfully, but these errors were encountered: