Page 1 of 1

password protect entire site with login page as first page -- Please help

Posted: Wed Apr 01, 2009 6:57 pm
by amhoffmaster
I'm stumped. I've read several other posts on this topic, but I'm still not clear what to do. I've read the Custom Content help and it doesn't help me with this particular situation.

The first page: I want a login page with only the login form (no navigation, but maybe a header graphic).

Content pages: I also want to make sure that the custom content block is added to every page so that no one can directly access the pages without first logging in...including the navigation. I can't figure out where to put the code in the template. If I put it in around the {content} block...it still shows the navigation.

I have two types of users: Residents and Board Members. I have successfully implemented the custom content block to restrict the Board Member pages to that group and they only display on the navigation when logged in as a member of that group. I have tried adding the custom content block on several areas of the templates that I'm using with no luck. Customer does not want the public to view any of their pages and I don't want them to have to manage an htaccess file.

I'm a designer not a programmer, so I'm really struggling with this. This is only my second CMSMS installation. Everything else installed fairly easily. Thanks in advance.

Re: password protect entire site with login page as first page -- Please help

Posted: Wed Apr 01, 2009 8:03 pm
by amhoffmaster
Ok, I figured out the login page. I used one of my other templates and removed the navigation div tags.

Still need an answer to password protecting the rest of the site.

Re: password protect entire site with login page as first page -- Please help

Posted: Wed Apr 01, 2009 8:18 pm
by jmcgin51
You put the CC tags around ALL the content you want protected.  If you don't want the menu displayed to non-logged-in-users, then make sure the {menu} call is inside the CC tags.


I usually do something like this:

IF user is logged in
display my normal page template
ELSE
display a very stripped-down template that basically says "sorry, you're not logged in", and possibly has a login form
END IF

Re: password protect entire site with login page as first page -- Please help

Posted: Wed Apr 01, 2009 9:44 pm
by amhoffmaster
That sounds like a good idea. I already have a stripped down template for the login page that I can use.
Can you be more specific with the code? I'm not a programmer. Thanks in advance.

Re: password protect entire site with login page as first page -- Please help

Posted: Wed Apr 01, 2009 11:13 pm
by jmcgin51
amhoffmaster wrote: Can you be more specific with the code? I'm not a programmer.
Me either.  I just pretend and hope my clients don't find out :D

How about this:

Code: Select all

{if $ccuser->loggedin() && $ccuser->memberof('anyauthorizedgroup')}
 display the content that the authorized group should be allowed to see
{else}
 display "sorry" message
{/if}

Re: password protect entire site with login page as first page -- Please help

Posted: Thu Apr 02, 2009 12:35 am
by amhoffmaster
That's funny! ;D

I tried putting the tag on several different areas of the page....the only thing it hides is the actual content.

Here's the code:

Code: Select all

{process_pagedata}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<__html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
{* Change lang="en" to the language of your site *}


<head>

<title>{sitename} - {title}</title>
{* The sitename is changed in Site Admin/Global settings. {title} is the name of each page *}

{metadata}
{* Don't remove this! Metadata is entered in Site Admin/Global settings. *}

{stylesheet}
{* This is how all the stylesheets attached to this template are linked to *}


{literal}
<__script__ type="text/JavaScript">
<!--
//pass min and max -measured against window width
function P7_MinMaxW(a,b){
	var nw="auto",w=document.documentElement.clientWidth;
	if(w>=b){nw=b+"px";}if(w<=a){nw=a+"px";}return nw;
}
//-->
</__script>
<!--[if lte IE 6]>
<style type="text/css">
#pagewrapper {width:expression(P7_MinMaxW(720,930));}
#container {height: 1%;}
</style>
<![endif]-->
{/literal}
{* The min and max page width for Internet Explorer is set here. For other browsers it's in the stylesheet "Layout: Left sidebar + 1 column" *}


</head>

</__body>

<div id="pagewrapper">


    {* start accessibility skip links *}
    <ul class="accessibility">
      <li>{anchor anchor='menu_vert' title='Skip to navigation' accesskey='n' text='Skip to navigation'}</li>
      <li>{anchor anchor='main' title='Skip to content' accesskey='s' text='Skip to content'}</li>
    </ul>
    {* end accessibility skip links *}


   {* Start Header, with logo image that links to the default start page. Logo image is changed in the stylesheet  "For template: Left menu + 1 column" *}
   <div id="header">
           <h1>{cms_selflink dir="start" text="$sitename"}</h1>
   
   </div>
   {* End Header *}



   {* Start Search *}
   <div id="search">
          {search}    </div>
   {* End Search *}


     {* Start Breadcrumbs *}
   <div class="breadcrumbs">
      <img src="images/cms/grad.jpg" />  {breadcrumbs starttext='You are here'  delimiter='»'}<br />
  <img src="images/cms/grad.jpg" /> To Contact the Front Desk, call <font color="#8c0b05">412-586-5968</font>.    
   </div>
   {* End Breadcrumbs *}



   {* Start Content (Navigation and Content columns) *}
   <div id="content">



      {* Start Sidebar *}
      <div id="sidebar">

      {* Start Navigation *}
      <div id="menu_vert">
         <h2 class="accessibility">Navigation</h2> 
		 
        {if $ccuser->loggedin() && $ccuser->memberof('Board')}
         {menu template='cssmenu.tpl' collapse='1' }
       {else}
          {menu template='simple_navigation.tpl' collapse='1' excludeprefix= 'BoardDownloads'}
       {*oops*}{/if}

<br >
      </div>
      {* End Navigation *}



      </div>
      {* End Sidebar *}


      {* Start Content Area *}
      <div id="main">
         <div style="float: right;">{print showbutton=true script=true}</div>
         <h2>{title}</h2>

{if $ccuser->loggedin() && $ccuser->memberof('Residents') }
{content}
{elseif $ccuser->loggedin() && $ccuser->memberof('Board')}
{content}
{else}
You are not authorized to view this page
{/if}



 <br />

       
      </div>
	  {* End Content Area *}


   </div>
   {* End Content *}


   {* Start Footer. Edit the footer in the Global Content Block called "footer" *}
   <div id="footer">
      {global_content name='footer'}
   </div>   
   {* End Footer  *}


</div>{* end pagewrapper *}
<__body>
</__html>
---------------------------

The code that I keep moving around is this:

Code: Select all

{if $ccuser->loggedin() && $ccuser->memberof('Residents') }
{content}
{elseif $ccuser->loggedin() && $ccuser->memberof('Board')}
{content}
{else}
You are not authorized to view this page
{/if}



It might work if I knew how to put the redirect code into the area that says "you are not authorized to view this page" But, I don't know how to do that.

Re: password protect entire site with login page as first page -- Please help

Posted: Thu Apr 02, 2009 1:04 am
by amhoffmaster
Ok, I found this post that explains how to do the redirect
http://blog.jofftastic.co.uk/2008/09/page-redirect-with-cms-made-simple/

Now, I just have one hurdle to overcome.
When I am logged in as Resident, I shouldn't have access to the Board Member docs. I don't have access to the pages, however, if I do a search for "Board", I see all of the documents that Board Members have uploaded. That's not good. I need to find out how to restrict the search so that it doesn't bring up those docs.

Re: password protect entire site with login page as first page -- Please help

Posted: Thu Apr 02, 2009 7:44 am
by alby
amhoffmaster wrote: When I am logged in as Resident, I shouldn't have access to the Board Member docs. I don't have access to the pages, however, if I do a search for "Board", I see all of the documents that Board Members have uploaded. That's not good. I need to find out how to restrict the search so that it doesn't bring up those docs.
Use Upload module for this

Alby

Re: password protect entire site with login page as first page -- Please help

Posted: Thu Apr 02, 2009 1:46 pm
by amhoffmaster
I am using the upload module. This is the type of result that's returned when I put in the word "board" in the search box to test it.

Front End File Management (Uploads) - March_Board_Member_Notes.doc (50%)

Although you can't download the file (unless you have permissions), the result still shows up in the search, which I don't want. I've tried unchecking "cache"  and "searchable" on the pages, reindexed the pages in the search module, and added the code mentioned in another post to the page. Nothing seems to keep these items from displaying in the search.

Re: password protect entire site with login page as first page -- Please help

Posted: Wed May 06, 2009 3:27 pm
by jmcgin51
amhoffmaster - I am also looking for a solution to this issue.  I think this could be solved by tying the "searchability" to the "Authorized FEU Groups" selection box in the Uploads Category editor.

In other words, Uploads should only be displayed in the search results IF the user has permission to view the file.  I'll submit this as a feature request.  Don't know how much work it would be to implement, but I definitely think it is a needed enhancement.

EDIT TO ADD:
http://dev.cmsmadesimple.org/feature_request/view/3400

Re: password protect entire site with login page as first page -- Please help

Posted: Wed May 06, 2009 6:59 pm
by Jeff
Is it possible to add a check to the Search Module's Results template to hide content if you don't have access to it?