开发者

User Authorization in KohanaPHP App vs Endless Loop

Wondering how to name this question. Think this is the best situation possible.

Situation: I got small app written in KohanaPHP framework. However there's one small bug that makes my crazy.

I got my own Core_Controller that is extended by every controller in this app. In constructor of this controller, I'm checking user profile status. So far so good. Although I'm facing a logical issue. It's called endless redirect loop. If I try to redirect (in Core_Controller constructor) user to Member_Controller it cannot be workig due to endless lopp. I understand why it happen.

Solution: I'm looking for a solution how to make it flexible. I tried to move this verification to a helper and call it in Core_Controller constructor. However, it can be working correctly.

Question: Do I have to put ver开发者_JAVA技巧ification in constructor of every single controller? IS there any universal method to do it?

Waiting for your thoughts.

M.A.


Just check if user is verified and the current request's action isn't something like member/verification, do the redirect.

And parent::__construct(); will call the parent constructor, so I don't see the problem in that either..


You need a condition where it doesn't redirect (on the page you have redirected to). You'll want some code similar to this.

if not member_controller then
    redirect to member_controller
else
    do nothing
endif

The else isn't needed, but just added so it's more clear to you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜