I’ve observed and repeated the factory design detailed at
artima - Modular Architectures with Ruby but
I would like something a little cleaner.
The details are such that I have 3 types of users: managers, employees
I’ve abstracted the user security API such that
Manager < User
Employee < User
Customer < User
and the User class has all of the authentication methods such as
“set_password”, “check_password”, etc.
Now, for the authentication controller.
I have my route mapping such that /authenticate/:user_type/:action
I’d like to have something similar to the following as my authentication
class Authenticate < ActionController::Base
@user = User.find(@params[:user_type], @params[:user][:email_address])
if @user and @user.check_password(@params[:user][:password])
render(:text => “Success”)
render(:text => “Failure”)
Make sense? Any thoughts/ideas appreciated.
Quis custodiet custodes ipsos?