Hello all,
I had a relatively simple question regarding some design tips within
Mason and mod_perl in an object oriented fashion.
Supposing an application requires a person to log in and there are
different levels of authentication. For example:
1. Administrator
2. Employee
3. Customer
When they log in, currently the autohandler will populate the %session
variable. For example, $session{user_id}, $session{branch_employee_number}
(for the Employee type) and $session{customer_number} (for the Customer
class).
This sounds obviously like something that can be coded in OO fashion:
User.pm which defines the abstract methods such as get_id, set_id,
get_login_name, etc, etc.
Then Administrator.pm, Employee.pm and Customer.pm would extend these
classes and implement the methods.
I am confused as to what is good practise to do this within
mod_perl/Mason.
Upon logging in, we retrieve their authentication level from the database
(when we check the username and password). Do I then create the object of
the corresponding user and put it into $session? Such as:
1. First Log in. Create object:
my $user_id = MyApp::Login::check_auth(....);
my $customer = new Customer($user_id);
2. Put the object in session:
$session{User} = $customer;
A few mouse clicks later, some Mason pages needs the user ID:
MyApp::do_something($session{User}.get_id());
Would this work? I apologize for my ignorance on this matter but I have
not found many resources about approaching this way online, especially
through mod_perl.
Thank you very much
Ogden
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users