I want to build a website with some simple social fetures. I wonder how to organize user profiles. My doubts are:

When example.com/user/someuser is executed

  • not logged user should see public profile without any edit profile options

  • logged user should see private profile if his profile is shown but public profile if someones else profile is shown

I plan to make it like this: profile controller class - check if user is logged

  • if no, show public profile view

  • if user is logged show public profile or private profile dependant on authorization

But what if someone put something in url like: edit or something? Please give some advice how t organize something like this, or maybe someone could give some links with tutorials or something?

有帮助吗?

解决方案

The basic idea is to check for authentication in the controller's before() method, which gets executed prior to the controllers action methods. Here are links to a couple of examples:

Official Kohana Documentation - Controller: Before and after

Unofficial Kohana 3 Wiki - Using Auth with template extended controllers

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top