Massive amounts of documentation has been added.
git-svn-id: http://svn.cleancode.org/svn/pickles@55 4d10bc64-7434-11dc-a737-d2d0f8310089
This commit is contained in:
parent
cbcfc9cc4f
commit
1784514696
20 changed files with 941 additions and 59 deletions
|
@ -1,7 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Security class
|
||||
*
|
||||
* Handles authenticating a user via an Apache login box.
|
||||
*
|
||||
* @package PICKLES
|
||||
* @author Joshua Sherman <josh@phpwithpickles.org>
|
||||
* @copyright 2007-2008 Joshua Sherman
|
||||
* @todo Make the SQL less specific, right now you have to use a table
|
||||
* named users, and use the email as the username. I will need to
|
||||
* move this to the configuration and allow the user to specify which
|
||||
* table to authenticate against, and what column names to use for the
|
||||
* username and password.
|
||||
*/
|
||||
class Security extends Object {
|
||||
|
||||
|
||||
/**
|
||||
* Authenticates the user
|
||||
*
|
||||
* Checks for the authentication variables to be passed in the $_SERVER super
|
||||
* global and attempts to authenticate the user against MySQL. If the user
|
||||
* cannot successfully they will be presented with a 401 Unauthorized page.
|
||||
*
|
||||
* @todo I'm sure someone will find the access denied message offensive, so
|
||||
* this will need to be made more generic. May also want to add in the
|
||||
* ability for someone to add a custom message and/or landing page in
|
||||
* the configuration as well.
|
||||
*/
|
||||
static function authenticate() {
|
||||
$db = DB::getInstance();
|
||||
$session = Session::getInstance();
|
||||
|
@ -36,6 +62,12 @@ class Security extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the user out
|
||||
*
|
||||
* Destroys the session, clears out the authentication variables in the
|
||||
* $_SERVER super global and redirects the user to the root of the site.
|
||||
*/
|
||||
static function logout() {
|
||||
$session = Session::getInstance();
|
||||
$session->destroy();
|
||||
|
@ -45,7 +77,6 @@ class Security extends Object {
|
|||
|
||||
header('Location: /');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue