gorgo666 Posted August 11, 2008 Share Posted August 11, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/119127-zend_auth-checking-for-authenticated-user/ Share on other sites More sharing options...
ignace Posted August 11, 2008 Share Posted August 11, 2008 If you would care to read a manual you would find that you can use Zend_Controller_Front plugins or use the init() or preDispatch() methods if you want specific behavior for a certain class. http://framework.zend.com/manual/en/ in case you wouldn't know where to find it! Quote Link to comment https://forums.phpfreaks.com/topic/119127-zend_auth-checking-for-authenticated-user/#findComment-613449 Share on other sites More sharing options...
gorgo666 Posted August 11, 2008 Author Share Posted August 11, 2008 Well no thanks for an extremely arrogant, ignorant and sarcastic reply. I do read the manual, but I do apologise for not having a 110% understanding of the subject as you obviously do. Quote Link to comment https://forums.phpfreaks.com/topic/119127-zend_auth-checking-for-authenticated-user/#findComment-613462 Share on other sites More sharing options...
ignace Posted August 11, 2008 Share Posted August 11, 2008 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/ Quote Link to comment https://forums.phpfreaks.com/topic/119127-zend_auth-checking-for-authenticated-user/#findComment-613481 Share on other sites More sharing options...
gorgo666 Posted August 11, 2008 Author Share Posted August 11, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/119127-zend_auth-checking-for-authenticated-user/#findComment-613512 Share on other sites More sharing options...
DarkWater Posted August 11, 2008 Share Posted August 11, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/119127-zend_auth-checking-for-authenticated-user/#findComment-613721 Share on other sites More sharing options...
448191 Posted August 11, 2008 Share Posted August 11, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/119127-zend_auth-checking-for-authenticated-user/#findComment-613783 Share on other sites More sharing options...
DarkWater Posted August 11, 2008 Share Posted August 11, 2008 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* >_< Quote Link to comment https://forums.phpfreaks.com/topic/119127-zend_auth-checking-for-authenticated-user/#findComment-613846 Share on other sites More sharing options...
gorgo666 Posted August 16, 2008 Author Share Posted August 16, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/119127-zend_auth-checking-for-authenticated-user/#findComment-617970 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.