How would you add Authentication

Asked by Ant on 2009-06-04

What would be the best way to add Authentication to LightVC?

Question information

English Edit question
LightVC Edit question
No assignee Edit question
Solved by:
Anthony Bush
Last query:
Last reply:
Best Anthony Bush (awbush) said : #1

Assuming you don't mean something like HTTP AUTH, I usually just make a "user" controller with login/logout actions that use CoughPHP for models, e.g. a simple example might have a user table like this:


And, I might add a "requireAuth" method to the AppController and call it only on the pages/actions that need authentication (or in AppController::beforeAction() if they all require authentication). This method would just check the session and redirect to the /user/login/ location if the user logged in. Of course, make sure not to "requireLogin" for that page, otherwise they wouldn't be able to log in.

But, you can use anything including ACL libraries from other vendors. That's the beauty of LightVC: pull in whatever other favorite tools from other projects you want, it isn't coupled to any of them.

Ant (ant-prowebsites) said : #2

Thanks Anthony Bush, that solved my question.