Jungle Dragon update »
FERDY CHRISTANT - AUG 5, 2008 (07:02:11 AM)
![]()
Coding for Jungle Dragon has finally started, so here is a small update...
I've mostly been working on the user management module, because almost everything in Jungle Dragon evolves around a user. User management for an internet-based web application is not something to take lightly, even though the general user experience I'm looking for is pretty standard:
- Users can sign up using a simple Registration form
- When validation is passed, the users gets an activation email
- After clicking the activation email, their account is active
- Next, they can login
- As a logged in user, they can access and edit their own preferences, including changing their email address, reset their password, etc
You'd be surprised at how much coding is required to implement the scenario above in a robust, secure way. I'm making good progress though. In my current development I'm focusing on the code and working of the scenario, a fancy user interface will follow as the last phase of the project, which is far, far away. So far I have the basic user registration and activation logic working, as well as the login/logout procedures.
The registration form is simply a view that is loaded by the registration controller. The form posts to this same controller, which takes care of the validation, and makes use of my User model class to interact with the database. I still have to code the forms to reset a password, or change the user's email address, as well as an admin view for managing users.
As for the authentication part, I'm making use of a slightly modified version of the Auth library. This library is not part of Code Igniter, yet it is a popular user-contributed library. Once properly configured and optimized for your situation, you can protect pages that require an authenticated user easily:
$this->load->library('auth');
$this->auth->restrict();
If users are not authenticated, the above statements will redirect the user to the login page. Next, upon successfull authentication, they will be redirected to the originally requested page, and their session will be set (using encrypted cookies). From then on, one can easily gather the session info of the user:
$logged_in = ($this->auth->logged_in()) ? true : false;
$logged_in_username = $this->auth->username();
$logged_in_userid = $this->auth->userid();
Further down the project, I will greatly enrich the Auth library, because authentication in Jungle Dragon is more complex than this simple binary system. For now, I really like the mechanism and ease of use.
Another baby step that I took was to implement a first part of the KarmaEngine. The KarmaEngine is a mechanism that rewards users karma credits based upon their actions and various circumstantial parameters. In terms of implementation, you can see this engine as a class that receives all kinds of events. It investigates the incoming event, and based on its parameters it will return the karma credit reward. So far, I have implemented only a single event. When a user signs up for Jungle Dragon, they will receive a signup reward of 100 karma credits. Even though this example is simple, it is conceptually interesting. Simply put, when all events are coded, I will have a single place to control and balance actions and rewards.
I know it must be boring for some of you to read an update like this. The project is in a very early stage and there is nothing to see yet. Still, in order to give both you and me some sense of progress on the long road to project completion, I'll continue to report on updates occassionally, as dull as they may be ;)


