Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid user provisioning when user already exists #8738

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/casa/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Besides a comprehensive graphical [admin console](./administration/admin-console

Casa is a plugin-oriented, Java web application. Existing functionality can be extended and new functionality and APIs can be introduced through plugins. Currently, there are plugins available for the following:

- [Accounts linking](./plugins/accts-linking/index.md)
- [Accounts linking](./plugins/accts-linking/account-linking-index.md)
- [Consent management](./plugins/consent-management.md)
- [Custom branding](./plugins/custom-branding.md)
- [2FA settings](./plugins/2fa-settings.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,24 @@ public class UidUtils {

public static String lookupUid(String uidRef, String uid, String extUid, String jansExtAttrName,
String jansExtUid) throws IOException {

if (uidRef == null) {
boolean uidPassed = uid != null;

if (uidPassed) {
logger.debug("Using uid passed: {}", uid);
return uid;
}


if (uidRef == null) {
//Find if the external account is already linked to a local one
User user = CdiUtil.bean(UserService.class).getUserByAttribute(jansExtAttrName, jansExtUid, true);

if (user == null) {
boolean uidPassed = uid != null;

if (uidPassed) {
logger.debug("Using uid passed: {}", uid);
return uid;
}

logger.info("Building a uid based on external id {}", extUid);
return extUid + "-" + randSuffix(3);
}
logger.info("Using uid of the account already linked to {}", extUid);

logger.info("Using uid of the account already linked to {}", jansExtUid);
return user.getUserId();
}

Expand Down