Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-11-03 18:09:10

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Help with Password Protect

Hi,

I’m using the IGN_Password_Protect plugin, but I’m not sure how BEST to use it, here is my sample page that I would like to protect, I want it to show the login form if not logged in, and show the content when logged in.

<txp:output_form form="header" />

...page contents...

</txp:output_form form="footer" />

this is the form I want to show, including the page has been protected:

		<fieldset id="login_container">
    <legend>Authorisation Required</legend>
    <form name="signup" action="" method="post">

    <p>The file <q><span>PAGE NAME GOES HERE</span></q> is protected. You must have an account with sufficient privileges to continue.</p>

    <ul>
        <li>
        	<label for="name">Username / ID</label>
            <input type="text" name="name" size="30" />
        </li>
        <li>
            <label for="email">Password</label> 
            <input type="text" name="email"  size="30" />
        </li>
        <li>
        	<label for="submit">&nbsp;</label>
			<button type="submit" class="submitBtn"><span>Log In</span></button>
			<button type="reset" class="resetBtn"><span>Cancel</span></button>
        </li>
    <ul>
    </form>
</fieldset>

~ Cameron

Offline

#2 2008-11-03 18:53:58

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Help with Password Protect

Just to add to this, I find the syntax confusing as the Help Doc claims some tags are depreciated, and I just want to make sure I get it right. I would also really appreciate some extra ideas, such as what can be done using the tags, e.g. logout, display logged in name etc. x


~ Cameron

Offline

#3 2008-11-03 20:16:45

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Help with Password Protect

any updates? thank you


~ Cameron

Offline

#4 2008-11-03 20:57:36

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Help with Password Protect

Posting in the plugin help thread might give better results.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#5 2008-11-03 21:01:23

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Help with Password Protect

MattD wrote:

Posting in the plugin help thread might give better results.

That thread seemed more plugin development orientated rather than help with setting it up, plus it goes all the way back to 2005, which means it contains the old tags and stuff, which is what is confusing me. x


~ Cameron

Offline

#6 2008-11-03 21:30:07

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Help with Password Protect

The plugin is still being actively supported, and plugin authors won’t always notice topics about their plugin posted elsewhere, so the plugin thread is really the best place to ask your question.

Offline

#7 2008-11-03 21:54:31

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Help with Password Protect

<txp:ign_if_not_logged_in>
	<!--
		Here is the XHTML validated login form:
	-->
	<form action="<txp:page_url />" method="post">
		<fieldset id="login_container">
			<legend>Authorisation Required</legend>
			<input type="hidden" name="login" value="Login" />
			<p>The file <txp:section title="1" /> is protected. You must have an account with sufficient privileges to continue.</p>
			<ul>
				<li>
					<label for="name">Username / ID</label>
					<input id="name" type="text" name="p_userid" value="" />
				</li>
				<li>
					<label for="password">Password</label> 
					<input id="password" type="password" name="p_password" value="" />
				</li>
				<li>
					<label for="remember">Remeber me?</label>
					<input id="remember" type="checkbox" name="stay" value="1" />
				</li>
				<li><button type="submit" class="submitBtn">Log In</button></li>
			</ul>
		</fieldset>
	</form>
<txp:else />
	<!--
		Here is the content when logged in.
	-->
	<p>Hi, logged in user!</p>
	<txp:article />
</txp:ign_if_not_logged_in>

I also validated the XHTML code. In example legend and fieldset are form elements, so those should be inside a form, and they aren’t. Also, removed second button. If you want to add two buttons, use <input type="button"(.*)/>, because little older browsers support only one button per form, because it was tought to be submitter initially. Also noted as bug by some ppl. Bug, or misreaden feature by browser devs, either way it doesn’t work on older browsers.

Last edited by Gocom (2008-11-03 21:54:57)

Offline

#8 2008-11-03 22:11:00

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Help with Password Protect

It’s not working properly, what is happening, is it is showing BOTH the login form and the Hello logged in user, ie the else tag isn’t working? When I login it then shows nothing, so I take it the else tag isnt working as an else tag should do? x

This is the code:

<txp:output_form form="html_head" />
<txp:output_form form="header" />

	<div id="container">

<txp:ign_if_not_logged_in>

<form action="<txp:page_url />" method="post">
		<fieldset id="login_container">
			<legend>Authorisation Required</legend>

			<div class="form_padding">

			<input type="hidden" name="login" value="Login" />

			<p>The file <span><txp:page_url /></span> is protected. You must have an account with sufficient privileges to view.</p>
			<ul>
				<li>
					<label for="name">Username / ID</label>
					<input id="name" type="text" name="p_userid" value="" />
				</li>
				<li>
					<label for="password">Password</label> 
					<input id="password" type="password" name="p_password" value="" />
				</li>
				<li>
					<label for="remember">Remeber me?</label>
					<input id="remember" type="checkbox" name="stay" value="1" />
				</li>
				<li><button type="submit" class="submitBtn"><span>Authenticate</span></button></li>
			</ul>
	</div>

</fieldset>
	</form>

<txp:else />

	<p>Hi, logged in user!</p>

	</txp:ign_if_not_logged_in>


	</div>

<txp:output_form form="footer" />

Last edited by driz (2008-11-03 22:20:08)


~ Cameron

Offline

#9 2008-11-03 22:23:30

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Help with Password Protect

I just tried this code in reverse using if_logged_in instead of if_not_logged_in, and it has worked!
Why doesn’t the above code work though???? I take it the else tag doesn’t work with the if_NOT_logged_in tag?

Also, if I logout and the url gets this: /?logout=1 and I am shown the login form, I CANNOT log back in, it just shows the login form, unless I change the URL to just the plain section, why is the /?logout=1 affecting it? x

Last edited by driz (2008-11-03 22:28:12)


~ Cameron

Offline

#10 2008-11-03 22:29:59

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,447
Website GitHub

Re: Help with Password Protect

driz wrote:

I just tried this code in reverse using if_logged_in instead of if_not_logged_in, and it has worked!

Mental! But it kind of makes more sense to use the positive logic for sanity’s sake.

Why doesn’t the above code work though???? x

*shrug* I don’t use the plugin but it might have something to do with this. If I read that right it looks like if_not_logged_in doesn’t take the else clause, for some reason.

Last edited by Bloke (2008-11-03 22:30:28)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#11 2008-11-03 22:39:06

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Help with Password Protect

Okies that’s cool, but the url? if my user logs out and wants to login again (for arguments sake) and the url has the /?logout=1 added, it won’t let me log back in. Why? and how do I fix it? x


~ Cameron

Offline

#12 2008-11-03 22:44:31

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Help with Password Protect

Cause you are login to the logout path :D To fix that, change the form’s action value et cetara.

Last edited by Gocom (2008-11-03 22:47:50)

Offline

Board footer

Powered by FluxBB