Skip to content

Commit

Permalink
fix: avoid user provisioning when user already exists (#8738)
Browse files Browse the repository at this point in the history
* fix: use uid of the user when existing #8734

Signed-off-by: jgomer2001 <bonustrack310@gmail.com>

* doc: fix broken link #8734

Signed-off-by: jgomer2001 <bonustrack310@gmail.com>

---------

Signed-off-by: jgomer2001 <bonustrack310@gmail.com>
Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com>
  • Loading branch information
jgomer2001 and moabu committed Jun 19, 2024
1 parent f602fd1 commit 75e15a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
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

0 comments on commit 75e15a7

Please sign in to comment.