Posted: Sat May 20, 2006 1:53 pm
As one other possible model to consider:
What if the Authentication Module were more of a code generator/factory:
What if the Authentication Module were more of a code generator/factory:
Code: Select all
$authenticationSource = new DbAuthenticator($connString,$tableName,$usernameCol, $passwordCol,$sessionStorageVar);
// or
$authenticationSource = new DBAuthenticator($dbResource,$tableName,$usernameCol,$passwordCol,$sessionStorageVar);
// using is_string, etc to behave appropriately
$authRequiredHandler = $authenticationSource->getAuthRequiredHandler();
/* note this would impose a requirement on the application to use the same interface for its handlers as for the handlers written here
* probably either the canHandle/invoke or the execute variety or both
*/
$loginCommand = $authenticationSource->getLoginCommand($usernameSource, $passwordSource);
$logoutComamnd = $authenticationSource->getLogoutCommand();
// application code
$frontControllor->addHandler($authRequiredHandler);
$frontControllor->registerAction("Login",$loginCommand);
$frontController->registerAction("Logout",$logoutCommand);
/* Note that we don't really care how the developer hooks the generated commands/handlers into their application. */