Sitecore - Prevent access to a page, but still show it in the navigation - authentication

In Sitecore I have denied access to a particular page for the anonymous user.
This works correctly, but it also means that the page does not appear in the navigation menus and sitemap (both XSLT).
What I would like is for the user to be able to see the link, but be redirected to a Register/Login page when they click on it.

You'd need to allow anonymous users to view the page for it to be visible in the menu and sitemap.
What you could do though is override the Sitecore.Pipelines.HttpRequest.HttpRequestProcessor to check if the page requires a login (by adding a RequiresLogin True/False to the template for example), then check if the user is logged in if not redirect to your login page.
Theres an example of overriding the HttpRequestProcessor here

You could wrap the rendering logic in the menus in a SecurityDisabler, so it would render all item links, even if the user "cant see" them.
using (SecurityDisabler disabler = new SecurityDisabler())
{
foreach (Item item in Sitecore.Context.Item.Children)
{
... render the link ...
}
}

Related

Shopify Liquid: Adding Sections to the Login Template

I have a client request to add manageable content to the login page. I assume this would work like managing any other page, simply create a section with the necessary schema and markup, then include that section ({% section 'section_name' %}) in the customers/login.liquid theme template. Problem is I don't see an option to select the login page in the page selection drop-down when customizing the theme. How do I allow my client to customize the login page via sections?
Thanks!
The actual login template cannot have manageable sections.
The closest workaround is to create a custom page template that includes a login form. The page can include manageable sections that are accessible when customizing the theme. The only issue is that all the automatically generated login url links will not go to this page, so any instances of those links need to be adjusted in the theme.
You can manually tell the customizer where to go by adding a hash(#) at the end of the url, followed by the shopify site path you want to visit/edit.
https://<domain>.myshopify.com/admin/themes/<theme-id>/editor#/account/login
Once you enter this in the browser url bar, you'll need to hit enter twice to get the page to reload properly.
If you do this and find it keeps sending you back to the homepage, it means that accounts are disabled on the Shopify store. You can change this by going to:
Shopify Admin > Settings > Checkout > Customer accounts
Then selecting either: Accounts are optional // Account are required

Why sitefinity list allows wrong page url or allows paging?

I am using sitefinity 10.1 MVC. When I used sitifinity list on my page then it allow my page to go to wrong URL. For example, my page link is www.example.com and when I try www.example.com/12, instead of taking me to 404 error page it allows this URL and lands on the actual page. I need to take www.example.com/12 to 404 page.
That's because the "Enable Parameter Validation" setting is checked (by default).
When it is checked, Sitefinity leaves the widgets on the page to determine whether they can handle this page or should return 404.
Until a widget says "no, I can't and should not handle this page", a normal page is returned. The List widget is not one that would complain in this case.
It overrides the HandleUnknownAction where it simply invokes the Index action of the controller and says "I am good with this page, you do what you want with it".
So what you can try is going to Title and Properties of the page and scroll down, expand the Advanced options and uncheck Enable Parameter Validation. Save and try again.

block redirect link to login in joomla and add a popup instead of that

In joomla the default function if a guest clicks a link with a registered access level, is to redirect guest to the login page.
Is there a way to show a popup instead, for all of registered access level links?
For example it redirects to
your.com/login.html
But i want to show a login-button before the guest is redirected.
I found another template where it works like this, but it wont work in my own template. How can I do it in my template?
if(JFactory::getUser()->guest) {
//do user logged out stuff
}
else {
//do user logged in stuff
}
There is no simple fix. The problem is that when it is added, you dont really have information about where a link leads to. If you create an article that is public, and you add a link to an article that is restricted, then joomla does not check this when you add the link.
In the event that joomla can know this beforehand, like restricted menu items, or listing of article links in a category, restricted links will not be displayed to a guest user.
If you want to try to change the behaviour like you want to, then I would consider in what situation this actually happens. If it is links in articles that is the main problem, then the best would be if the editors, when adding links to restricted content, also added a predefined class or something to this link. Then use JQuery to disable the link and display a popup on click. A similar approach could be used in other contexts.

Add a Sign in portlet on the login page

I am building a basic login page using the existing sign-in portlet.
I just want to have a functionality that when a user access the website, right now localhost:8080, the sign-in portlet should pop up!
Is this doable? If so, Can someone please hint me how this can be done?
This is how the default page looks like right now:
To log in, I have to explicitely click on the "sign-in" blue button and then it pops out a modal sign in portlet.
But what I am trying to do here is:
Whenever a user clicks on the default url, it should immediately ask the user to login rather than showing a blank page with a sign-in button (something like the output image)
Or even a modal sign-in box (Whatever is easy to customize.)
and
Whenever a user hits any other url for eg. localhost:8080/web/project1/home and if the user is not signed in, it should force him to sign in first.
Two possibilities out of the box:
place nothing but the sign in portlet on the homepage, appearing at that location (typically /web/guest/home)
protect your default page to be not visible to the guest user (this will automatically forward to the sign-in portlet) - see the "Permissions" button on the "Manage Pages" interface
There are more, but these seem to be the first and most obvious ones. Let me know if one of them works for you or what the reason for your request is
From what I understand, you want the Login Portlet to popup as a modal window/lightbox on the current page (i.e. without leaving the page). AFAIK, to achieve this, you'll have to develop all your portlets to use AJAX to create links that point protected resources. So when you get an unauthenticated request, you can stay on the same page and show login dialog.
This is high-level approach. You'll need to 1) embed the Login portlet in your theme and 2) put the below javascript functionality in Theme:
callback function - to handle response for unauthenticated request,
to render modal/lightbox
You might face surprises while implementing this.

change default joomla login page

i'm working on a Joomla web site where i would like to change the default authentication page.
i created a new login menu item and i've tried to hide the com content area so that the login form don't show. instead of the default login form i placed a new better looking login module.
now i'm trying to make this page the default login page.
There are a couple areas in the site where access is restricted to registered users. and if clicked it leads to the default joomla login page. i want the user to be redirected to login from the new one.
can you please help?
The easiest way to obtain your own custom login page is to override the default joomla layout template.
It's actually very easy to do.
Start with your template. In the template directories, you'll need to have an html folder in your template. Inside of that, you'll need a com_users directory, and inside of that - a login folder. Like this:
/templates/YOURTEMPLATE/html/com_users/login
Then, copy /components/com_users/views/login/tmpl/default_login.php into your new login folder you just created.
From here, you can customize the default_login.php file to your hearts content. Be sure to keep the field names and hidden fields intact - be sure to only manipulate layout elements and avoid changing anything to do with the form, form name, destination or fields.
You can do the same for the logout template - and as a bonus, it goes in the same folder in your template.