How would you add Authentication

Asked by Ant

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

Question information

Language:
English Edit question
Status:
Solved
For:
LightVC Edit question
Assignee:
No assignee Edit question
Solved by:
Anthony Bush
Solved:
Last query:
Last reply:
Revision history for this message
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:

    user_id
    username
    password
    is_active

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.

Revision history for this message
Ant (ant-prowebsites) said :
#2

Thanks Anthony Bush, that solved my question.