OAuthRealm should not overwrite custom AuthRequest parameters
If the incoming AuthRequest already has pre-initialized email address or display name and it is allowed to customize these parameters in the account settings, ignore the parameters coming from the OAuth provider. Change-Id: I77403a10c68cd6c9306aab32277b5ddd02e2539d Signed-off-by: Michael Ochmann <michael.ochmann@sap.com>
This commit is contained in:
@@ -104,10 +104,14 @@ public class OAuthRealm extends AbstractRealm {
|
||||
if (userInfo == null) {
|
||||
throw new AccountException("Cannot authenticate");
|
||||
}
|
||||
if (!Strings.isNullOrEmpty(userInfo.getEmailAddress())) {
|
||||
if (!Strings.isNullOrEmpty(userInfo.getEmailAddress())
|
||||
&& (Strings.isNullOrEmpty(who.getUserName())
|
||||
|| !allowsEdit(FieldName.REGISTER_NEW_EMAIL))) {
|
||||
who.setEmailAddress(userInfo.getEmailAddress());
|
||||
}
|
||||
if (!Strings.isNullOrEmpty(userInfo.getDisplayName())) {
|
||||
if (!Strings.isNullOrEmpty(userInfo.getDisplayName())
|
||||
&& (Strings.isNullOrEmpty(who.getDisplayName())
|
||||
|| !allowsEdit(FieldName.FULL_NAME))) {
|
||||
who.setDisplayName(userInfo.getDisplayName());
|
||||
}
|
||||
return who;
|
||||
|
||||
Reference in New Issue
Block a user