Page requiring authentication, but visible on main menu?

If you have questions about using mojoPortal, you can post them here.

You may want to first review our site administration documentation to see if your question is answered there.

This thread is closed to new posts. You must sign in to post in the forums.
4/15/2008 6:05:48 AM
Gravatar
Total Posts 15

Page requiring authentication, but visible on main menu?

Hi,

Is it possible to have a 'root' level page (e.g. 'Client Area') visible on the main portal menu, but have the linked page require authentication?  It appears the only way to see the link in the menu (is by logging in first).  I guess the behaviour I'm looking for is for the menu link to redirect to the login page with a 'returnurl' as my client page.

I'll have a dig around the code in the meantime and see if I can find a way...

Cheers,

Matt

4/15/2008 6:37:38 AM
Gravatar
Total Posts 15

Re: Page requiring authentication, but visible on main menu?

Just  had  a bit of a look and it seems I almost need the reverse of 'hide after login' - so a setting against each page that will allow the page to show in the menu if unauthenticated.  The code seems to have some specifics relating to the 'level'  of the sitemapnode.

I'll see what i can come up with....

4/15/2008 7:25:55 AM
Gravatar
Total Posts 15

Re: Page requiring authentication, but visible on main menu?

Just creating a new page setting (ShowInMenuIfUnauthenticated) - a bit long I know.  Have the basics working locally as I'd like.  I  haven't got latest code/database however at the moment so would need to update from SVN before 'actually'  making the change (with DB changes too).  I'm  just hardcoding a 'true' for the moment.

The following shows the amended logic in SiteMenu.aspx.cs. I basically worked backwards from here and filled in the gaps until it built.  I'd have to do some more testing as I'd only want the setting to come into play if the page 'required' authentication.

I'd be interested in your thoughts on this approach and whether you think it's worth adding...

cheers,

Matt

protected void pageMenu_MenuItemDataBound(object sender, MenuEventArgs e)
{
Menu menu = (Menu)sender;
mojoSiteMapNode mapNode = (mojoSiteMapNode)e.Item.DataItem;
if (mapNode.MenuImage.Length > 0)
{
e.Item.ImageUrl = mapNode.MenuImage;
}

if (mapNode.OpenInNewWindow)
{
e.Item.Target = "_blank";
}

// added this 2007-09-07
// to solve treeview expand issue when page name is the same
// as Page Name was used for value if not set explicitly
e.Item.Value = mapNode.PageGuid.ToString();

bool remove = false;

if (!(
(isAdmin)
|| (
(isContentAdmin)
&& (mapNode.Roles != null)
&& (!(mapNode.Roles.Count == 1)
&& (mapNode.Roles[0].ToString() == "Admins")
)
)
|| ((isContentAdmin) && (mapNode.Roles == null))
|| (
(mapNode.Roles != null)
&&(WebUser.IsInRoles(mapNode.Roles))
)
)//MS
&&
(
//not authenticated, but allow
!(Request.IsAuthenticated) && !(mapNode.ShowInMenuIfUnauthenticated)
)
)
{
remove = true;
}
 

4/15/2008 7:31:46 AM
Gravatar
Total Posts 18439

Re: Page requiring authentication, but visible on main menu?

This is really not needed. You can achieve the result without it.

1. Create the page that requires authentication (ok its not visible in the menu).

2. Create another page that is visible to all users

3. For the second page set the url to the fully qualified url of the first page. ie http://yoursite/yourpage.aspx

Now the second page is visible in the menu but clicking the link since it points to the first page, the user is prompted to login then redirected to teh no longer hidden page. You may also want to uncheck the "include in menu" for the first page so it doesn't appear in the menu after login since it already has a link via the second page.

Hope it helps,

Joe

4/15/2008 7:40:55 AM
Gravatar
Total Posts 15

Re: Page requiring authentication, but visible on main menu?

hehe.

I knew you'd reply quickly Joe, and I also thought there'd be a solution.  I was actually almost hoping I could catch you out with that one, but you came up trumps again.  Consider my change abandoned :-)

Thanks again. Your support for this product is truly amazing and as a developer I couldn't wish for anything more - seriously.  I'm so glad I ditched DNN.

Matt

4/16/2008 9:46:55 AM
Gravatar
Total Posts 18439

Re: Page requiring authentication, but visible on main menu?

Thanks Matt! Your comments about mojoPortal and the support I provide made my day!

I hope some day to achieve the same level of success that DNN has achieved so any help spreading the word to other developers is very much appreciated.

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.