Expand my Community achievements bar.

SOLVED

AEM ClientContext doesn't recognize me as logged in

Avatar

Level 8

I have a custom identity provider that extends ExternalIdentityProvider and I have everything configured to where I can successfully login to AEM on author/publish/dispatcher using a user from the API.  The user is also synced with all of the custom properties.  In my authenticate method, I have the following

@Override public ExternalUser authenticate(Credentials credentials) throws ExternalIdentityException, LoginException { SimpleCredentials simpleCredentials = (SimpleCredentials)credentials; JSONObject login = UserService.login(simpleCredentials); Map<String, Object> userProperties = UserHelper.getUserProperties(login); if (userProperties.containsKey("customProperty")) { log.info("** USER IS LOGGED IN **"); return createIdentity(simpleCredentials.getUserID(), userProperties); } throw new LoginException("Error Logging In"); }

This successfully is executed and the info log is output correctly.  I see the user created in CRXDE in it's correct location also.

I then have a filter that checks for a specific location under the page path, let's just says it's "/content/site/en" and that the extension is HTML, if those conditions are true, i check to see if the user is logged in using the following code

public static Boolean isLoggedIn(SlingHttpServletRequest request) { logger.debug("** Checking if User is logged in **"); User user = request.getResourceResolver().adaptTo(User.class); try { if (user == null || user.getID().equals("anonymous")) { logger.debug("** User is NOT logged in **"); return false; } logger.debug("** User IS logged in: " + user.getID() + " **"); return true; } catch(Exception e) { return false; } }

My log is successfully outputting that the user is logged in on every page load.

If I then check the CQ_Analytics.ProfileDataMgr object, it does NOT recognize me as logged in.  This is the output

data: Object authorizableId: "anonymous" authorizableId_xss: "anonymous" avatar: "/etc/designs/default/images/social/avatar.png" formattedName: "anonymous" formattedName_xss: "anonymous" isLoggedIn: "false" isLoggedIn_xss: "false" path: "/home/users/W/WiGREN12Dh6nHZhH0v_6/profile"

However, if I look at the "initProperty" object, it has all of my custom profile properties and also specifies that i'm logged in

initProperty: Object AUTO_FILL_CON: "Y" AUTO_FILL_CON_xss: "Y" AUTO_FILL_REQ: "Y" AUTO_FILL_REQ_xss: "Y" AUTO_FILL_SHP: "Y" AUTO_FILL_SHP_xss: "Y" AUTO_FILL_TPB: "N" AUTO_FILL_TPB_xss: "N" BOL_DEFAULT_TEMP: "" BOL_DEFAULT_TEMP_xss: "" BOL_PREVIOUS: "Y" BOL_PREVIOUS_xss: "Y" CALENDAR: "Y" CALENDAR_xss: "Y" CHG_CALC_LIST: "Y" CHG_CALC_LIST_xss: "Y" COMDTY_DISPLAY_OPT: "A" COMDTY_DISPLAY_OPT_xss: "A" CONTACT_AUTOLOAD: "D" CONTACT_AUTOLOAD_xss: "D" accountNumber: "005012" accountNumber_xss: "005012" authorizableId: "005012" authorizableId_xss: "005012" avatar: "http://www.gravatar.com/avatar/email@email.com?d=mm&s=32&r=g" firstName: "NAME" firstName_xss: "NAME" formattedName: "NAME NAME" formattedName_xss: "NAME NAME" isLoggedIn: true isLoggedIn_xss: "true"

Why cannot access the user information on the profile object?  This is preventing me from grabbing the information i need for displaying user information on the web site.

This is AEM 6.1 with all hot fixes.

1 Accepted Solution

Avatar

Correct answer by
Level 8

I figured it out.  After looking at the Geometrixx code, I had to add the following on my form submission

CQ_Analytics.ProfileDataMgr.clear();

Then when the page reloads, the profile is correct.

View solution in original post

8 Replies

Avatar

Level 10

If you create a new AEM user (from siteadmin)- are you seeing this issue? 

Avatar

Level 8

Yes.

data: Object authorizableId: "anonymous" authorizableId_xss: "anonymous" avatar: "/etc/designs/default/images/social/avatar.png" formattedName: "anonymous" formattedName_xss: "anonymous" isLoggedIn: "false" isLoggedIn_xss: "false" path: "/home/users/W/WiGREN12Dh6nHZhH0v_6/profile" initProperty: Object authorizableId: "testuser" authorizableId_xss: "testuser" avatar: "/etc/designs/default/images/social/avatar.png" familyName: "Asling" familyName_xss: "Asling" formattedName: "Lee Asling" formattedName_xss: "Lee Asling" givenName: "Lee" givenName_xss: "Lee" isLoggedIn: true isLoggedIn_xss: "true" path: "/home/users/group/UaSczsMtb18XGcQ3o0Tq/profile"

Avatar

Level 8

It also does this using Geometrixx Outdoors.

Avatar

Level 10

Clearing the browser cookies with the real users should resolve your issue. If not file a support request by repeat the test case and attach the har file, all log file from webserver,dispatcher,publisher.  Steps to generate har file at https://help.tenderapp.com/kb/troubleshooting-your-tender-site/generating-an-har-file

Avatar

Level 8

Sham HC wrote...

Clearing the browser cookies with the real users should resolve your issue. If not file a support request by repeat the test case and attach the har file, all log file from webserver,dispatcher,publisher.  Steps to generate har file at https://help.tenderapp.com/kb/troubleshooting-your-tender-site/generating-an-har-file

 

I'm using an incognito window, so browser cookies are definitely not the issue.  I guess I'll submit a ticket, but I really need someone to help faster than what they respond so i'll keep an eye out here too.

Avatar

Level 10

I have never seen this issue - so it may be some sort of bug that Sham suggest. 

Avatar

Correct answer by
Level 8

I figured it out.  After looking at the Geometrixx code, I had to add the following on my form submission

CQ_Analytics.ProfileDataMgr.clear();

Then when the page reloads, the profile is correct.

Avatar

Level 10

leeasling wrote...

I figured it out.  After looking at the Geometrixx code, I had to add the following on my form submission

  1. CQ_Analytics.ProfileDataMgr.clear();

Then when the page reloads, the profile is correct.

 


That is the reason I asked first to clear the browser cookie to make sure not missed this.