Auto-login Broke
From the mailing list I can reproduce this behavior on demo.dotcms.com by logging in as "[email protected]" with "Remember me" checked, then quitting/relaunching my browser and loading demo.dotcms.com. Instead of being automatically logged in, you will see a com.dotmarketing.business.NoSuchUserException in the log file.
The auto-login cookie's value is an encrypted version of the user's ID, e.g. dotcms.org.2806. This is set on line 260 of the LoginFactory class.
autoLoginCookie = new Cookie(WebKeys.CMS_USER_ID_COOKIE, APILocator.getUserAPI().encryptUserId(user.getUserId()));
A commit made, I believe, as part of issue-1644 (https://github.com/dotCMS/dotCMS/blob/52c90af1edab58496a0fd8166bc82141963fc3b1/src/com/dotmarketing/cms/login/factories/LoginFactory.java#L46-L50) switches the lookup of the user from loadUserById to loadByUserByEmail. Since the value of decryptedId is not an email address this will always result in a NoSuchUserException.
String decryptedId = PublicEncryptionFactory.decryptString(encryptedId);
//User user = APILocator.getUserAPI().loadUserById(decryptedId,APILocator.getUserAPI().getSystemUser(),false);
/*Custom Code*/
User user = APILocator.getUserAPI().loadByUserByEmail(decryptedId,APILocator.getUserAPI().getSystemUser(),false);
/* End of Custom Code */
Reverting to loadByUserByEmail results in the standard auto-login once again working. While this is easy to work around, I wanted to make sure I wasn't missing something here. The Salesforce logic in LoginFactory is currently within a catch block that is executed if the user could not be found and if useSalesForceLoginFilter is true. With the current implementation, I wouldn't expect the user to ever be found.
Thanks for filing this @jtesser.
This was fixed here https://github.com/dotCMS/dotCMS/pull/4538
@ravit the was assigned to you but is now fixed
@jtesser This one is actually separate. The pull request I submitted was a fix for the backend auto-login. This bug deals with the front end auto-login. I fixed it in a plugin by only using loadUserById and not loadByUserByEmail. I didn't submit this fix to you all as I don't have visibility into the Salesforce logic that is part of the enterprise jar nor a way to test that this doesn't break the Salesforce integration in some manner.
User user = APILocator.getUserAPI().loadUserById(decryptedId,APILocator.getUserAPI().getSystemUser(),false);
@jtesser Can this one be reopened based on my comment above?
Fixed, tested on master-2.5, mySQL...