LPS-31985 User cannot view the site that they are assigned to when "permissions.check.guest.enabled=false" is set

Hi,

Extra condition introduced by commits d5c516e4097d0859f8dc2379e57f23cb85a18d15 and 359f7e07704163c1010366047000b028d4e69ba1 causes this regression issue.

if ((layout == null) || layout.isPrivateLayout()) {

	// Check the Guest site

	Group guestGroup = GroupLocalServiceUtil.getGroup(
		user.getCompanyId(), GroupConstants.GUEST);

	layouts = LayoutLocalServiceUtil.getLayouts(
		guestGroup.getGroupId(), false,
		LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);

	if (layouts.size() > 0) {
		layout = layouts.get(0);
	}
}

The problem with the new condition in the last step is that it is too permissive. Allowing "layout" to be private makes only sense, when a user is logged in. Otherwise - for instance in case of initiating a login sequence - we'll have to fall back to a default public layout. Currently we replace the user's private layout to guest's default layout in this ticket's scenario and cause this regression.

The fix is to limit this change and use the guest layout only, when the user is not authenticated and the destination layout set is private.

Cheers,
Laci.