Jump to content

Zend_Auth checking for authenticated user


gorgo666

Recommended Posts

Hi all

 

I'm just messing around with Zend, trying to get to grips with it.  I've created a little application with a fully working login system.  I'm just implementing code to stop people from referencing URLs directly, because the current set up means that even if they aren't logged on, they can get access to specified page.

 

I'm aware how to do this - I can simply add something along the lines of:

	function indexAction()
{
	if ($this->authenticated) {
		// Render page		
	} else {
                        // Redirect to login
		$this->_redirect('/auth/login');
	}

}

 

But, I have a controller called Customer that has several actions - index, add, edit and delete.  In the above code snippet I have added in the code for the index action, but if you navigate to http://site/customer/edit or /add or /delete, you can still get through.

 

Because I'm lazy, and I can't be bothered to repeat the code for each action, is there a way I can extend it through the entire controller to save time?

 

Link to comment
Share on other sites

well sorry for my behaviour but i really hate people who are storming the forums just to get quick answers without even trying to find it through google

 

if you are not such a guy than i ow you my apologies

 

i am also using the zend framework and actually the last place i use is a forum, because the answers are to slow :)

my favourite resources are:

http://www.zftutorials.com/

http://akrabat.com/

http://devzone.zend.com/

 

Link to comment
Share on other sites

I do use Google and that's why I utilise all three of those links you mention, however I considered my problem to be reasonably specific so thought that someone could have helped on these forums.

 

However, sadly, the membership seems to be partly comprised of arrogant, unhelpful people such as yourself who quote things such as "use the search" or "use Google"; or in this case "use the manual".  I suppose that this behaviour can be expected with the advent of the forum but it's annoying nonetheless.

 

Forget about it, problem still unsolved.

Link to comment
Share on other sites

I do use Google and that's why I utilise all three of those links you mention, however I considered my problem to be reasonably specific so thought that someone could have helped on these forums.

 

However, sadly, the membership seems to be partly comprised of arrogant, unhelpful people such as yourself who quote things such as "use the search" or "use Google"; or in this case "use the manual".  I suppose that this behaviour can be expected with the advent of the forum but it's annoying nonetheless.

 

Forget about it, problem still unsolved.

 

And once in a while, those arrogant, unhelpful people are absolutely right.  You're being rather ridiculous about this.  If it shows it right in the manual, then go look in the manual.  And I don't see how the problem is unsolved if he provided you with an answer.  You just use init() or preDispatch() to use that code controller-wide.  I use CakePHP when I want to use a framework, but I'd assume that it would be the same thing in this case.  Those methods are both automatically called at certain points in the controller's lifetime to provide some broad functionality to the controller.

 

Now, please stop being a jerk, we're trying to help you and telling you to read the manual once in a while is not a bad thing.

Link to comment
Share on other sites

R T F M is only so helpful, but bitching about it is even less helpful. Shame on all of you <wiggles finger in disapproval/>

 

Anyway.

 

Forget about it, problem still unsolved.

 

You know how to use Zend_Auth (as you have a working login system), you now know you can use either init() or preDispatch() (I recommend the latter) to implement a check that will be performed for all actions in a controller.

 

So what's not solved?

Link to comment
Share on other sites

R T F M is only so helpful, but bitching about it is even less helpful. Shame on all of you <wiggles finger in disapproval/>

 

Anyway.

 

Forget about it, problem still unsolved.

 

You know how to use Zend_Auth (as you have a working login system), you now know you can use either init() or preDispatch() (I recommend the latter) to implement a check that will be performed for all actions in a controller.

 

So what's not solved?

 

Yeah, I don't know what's unsolved about it either. >_>  And ignace wasn't just like "rtfm".  He actually told him how he could do it then told him to read the manual because it's probably clearly stated in there. >_<  *Is disappointed about petty arguments on programming forums* >_<

Link to comment
Share on other sites

DarkWater, sorry for the late reply, and I'm sorry I did snap at it but to be honest there was nothing too challenging about my question.  I asked it because I personally believed I had exhausted the "Read The Manual" routes.  If I hadn't have read the manual in the first place, I wouldn't be here because I wouldn't have managed to get a basic Zend set up going...

 

My annoyance doesn't necessary come from someone saying "read the manual".  The reason I got so bloody annoyed is because of Ignace's attitude.  There are many ways to get your point across and sometimes saying "if you cared to read the manual you'd know..." etc isn't the best way to do it.  If, however, he/she had  told me "well you could check out xyz section of the manual, that should help you out"...

 

I can see your point, and I agree.  Can you see mine?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.