Tuesday, December 30, 2014

Kohana Auth Roles

After using Wordpress for quite some time, I've learned quite a bit about PHP. I've got to give props to the Wordpress community for being a wonderful teacher, and now I've started working with a PHP framework.

The PHP framework of choice is Kohana 3.3.2

I've started building a site and need to create a user login system with several user roles akin to Wordpress.

Let me start with a description of my environment.

I've enabled a couple modules so far, Auth, Orm, and Database.
I've built a website controller which extends Controller_Template.
I've made a User controller and Model (which I might mention now that much of the work is done already, so check the Orm Module classes and view the Auth stuff if you are having troubles)

The Problem which I have just overcome cam into play when I started fiddling with the built-in Roles. Once I changed those in the database from "admin" and "login" to "admin","owner","scheduler","assistant", and "member". Once I had done this, I was unable to login.

The problem: The _login() function validates the user's role against the "login" role. If that role doesn't exist, no user can login. I found that function in modules/orm/classes/Kohana/Auth/ORM.php. Changing that file is bad form btw. So, it's best to follow the cascading file system to create a duplicate of that file with your changes that will take priority in the load order.

There are more details to come but I thought I would get my findings out as fast as possible.

No comments:

Post a Comment