Displaying an Alert to create a Login Form when saving a Home menu item#19535
Displaying an Alert to create a Login Form when saving a Home menu item#19535infograf768 wants to merge 2 commits intojoomla:3.10-devfrom
Conversation
|
Maybe it would be good to display such warning only if there is no published menu item for |
arguably, such a menu item for login can exist, but always showing this warning, for the -rare- case that the home page is non-public access is a kind of annoying, so it is best to show it only if needed |
|
I do not agree with this being added to the core. It is a very specific use case that will not apply to the majority of the web sites out there. If we are to start adding messages for every possibility then it will get crazy. The correct place for this information is in the documentation |
We can't base ourselves on the Accesses as these may have been totally modified.
How many times does a site admin modifies home pages?
As usual, all that can help users not making mistakes, specially for non-English speaking people as Docs is barely translated, creates issues for you. No comments. |
|
it is possible to make a simple check if the home page menu item has currently non-public access and only then display it ! it is a very good trade-off , and that is the way things should work, something bad is detected , provide some immediate valueable feedback, instead of "expecting users to read documentation", plus people may change access just by mistake, i have seen it happen , and i have done it once or twice myself |
|
@ggppdk that would be much better than this PR |
|
If we can detect a misconfiguration of the site clearly and if we can give the user proper advice how to fix it, then we should do it. |
|
@rdeutz I agree with that. I just dont agree with this PR in its current form which always displays it |
|
@csthomas @ggppdk @brianteeman Appreciate you have at last figured out we do not need sending back people to the docs for everything. |
|
If we can absolutely guarantee that the public access level will always be "1" then IMO this is fine, otherwise we need to come up with a way to account for users who can and do customize viewing access levels and user group configurations. |
|
i cant see how that guarantee can be given |
This is why my original PR did not include access check as stated before. |
|
And likewise Brian has a valid point about not always showing the notice when saving a home item. I don't know what the right answer is for this but we can't just blindly always show the notice and we can't blindly make an assumption about a part of the system that can be configured by users. |
|
Reading through all the related issues and I haven't yet found out what and why broke the previous behaviour whereby the login menu was now required. Surely that is the cause of the problem and it is there we should look for a solution. |
|
Good point, but i think it is possible we get the guest access level(s) // Check if current menu item is a home page, and it has an access level that is granted to guests
if ($data['home'] && $data['published'])
{
$guest_accessible = in_array($data['access'], JAccess::getAuthorisedViewLevels(0));
if (!$guest_accessible)
{
JFactory::getApplication()->enqueueMessage(JText::_('COM_MENUS_CREATE_LOGIN_FORM'),'warning');
}
} |
|
As a user that likes to be spoofed, I would hate for Joomla to bother me with too many assumptions, like assuming I want visitors to login. Maybe I missunderstood this.? |
Maybe we can start from this joomla-cms/libraries/src/Access/Access.php Line 1070 in e9af548 |
|
it is about the 99%+of websites
so if the message is not relevant to some websites, then ok, they know what they are doing, @csthomas i think the code that i posted works properly so we do not need care about "Public" access level at all |
|
So if public access level is not relevant, Something like this
|
|
I guess you folks really do like wasting your time. |
|
@ggppdk I did not see your comment, when I was adding mine. |
i think yes, i think it used to be an issue, and then it was fixed at some point in the past and then it stopped working again in J3.8.x ? About the code i proposed above, it can be useful in other cases, |
no the redirection loop , is still happening with J3.8.4 router changes reverted\ if there is no menu item (of any type, registration, profile, login, etc) for 'com_users' that is published and accessible by guest user then home page menu item is selected (which is not accessible) and you get a redirection loop was this ever "working" without a menu item for of 'com_users' ?
the login URL needs to be created without any menu Itemid if the home page menu is not accessible |
|
Read the original issue - this started at J3.7 |
|
I tested 3.6.5 and the difference is that no Itemid is added to the link when a login form is not present. What do you think? |
|
Yes your code will work, and will prevent the redirect loop just, it is better to also typecast $menuId[1] to integer
And actually the fix is correct to be placed there |
|
I will propose the PR a bit later. |
|
Please test #19559 Closing this as we have a better patch. |
|
IMO this PR with @ggppdk changes #19535 (comment) would be enough for J3.x |
|
I do not think so as it includes the guest access in the array and, for sure, i would never give the guest access to a home page. |
it is not about 'public' or about 'guest' access level
So ONLY if the home page menu item has any of the access levels
only then your unlogged visitor will be able to see the home page without being redirected to login screen,
So in fact checking if home page has access level public, was wrong for 2 reasons
still this PR can be useful but with adding a different warning
the message of this PR can now become |
would in this case rather be I guess :
Before modifying this, I need to know if it would be accepted. |
|
I found a way to keep JRoute in #19559 Please let me know what you think |
|
Hello @infograf768, thank you for your contribution. We are really sorry that it took so long to respond to you. We've discussed this PR extensively in the CMS maintainer team and decided on closing it for now. We agree that a warning would be good if there is no login form and the homepage is non-public, but that warning should only show up when that actually is the case. Since access levels can be changed, simply checking for the ID 1 is not enough. We would be very happy if you could open a new PR against 4.2 with the proper checks and we will try our best to process that as soon as possible. It definitely shouldn't have to wait another 4 years... |
|
Closing and reopen #15730. |
Pull Request for Issue #15730
Summary of Changes
If Home page(s) (in monolingual as well as multilingual sites) needs login to be displayed, it is necessary to also create and publish a Login Form menu item to get an Itemid.
As the former attempts to solve this via code have failed while keeping an Itemid and 3.8.4 router changes are likely to be reverted ( #19512 ), this will remind sites administrator to do so.
It is impossible to limit the display in function of the Access (at least I don't know how to) as users may have modified the default Accesses.
Testing Instructions
Patch and save a Home menu item.
After patch