AuthComponent Class Reference

Public Member Functions | |
| action ($action= ':controller/:action') | |
| allow () | |
| deny () | |
| & | getModel ($name=null) |
| hashPasswords ($data) | |
| identify ($user=null, $conditions=null) | |
| initialize (&$controller) | |
| isAuthorized ($type=null, $object=null, $user=null) | |
| login ($data=null) | |
| logout () | |
| mapActions ($map=array()) | |
| password ($password) | |
| redirect ($url=null) | |
| shutdown (&$controller) | |
| startup (&$controller) | |
| user ($key=null) | |
| validate ($object, $user=null, $action=null) | |
Public Attributes | |
| $_loggedIn = false | |
| $actionMap | |
| $actionPath = null | |
| $ajaxLogin = null | |
| $allowedActions = array() | |
| $authenticate = null | |
| $authError = null | |
| $authorize = false | |
| $autoRedirect = true | |
| $components = array('Session', 'RequestHandler') | |
| $data = array() | |
| $fields = array('username' => 'username', 'password' => 'password') | |
| $loginAction = null | |
| $loginError = null | |
| $loginRedirect = null | |
| $logoutRedirect = null | |
| $object = null | |
| $params = array() | |
| $sessionKey = null | |
| $userModel = 'User' | |
| $userScope = array() | |
Detailed Description
Definition at line 41 of file auth.php.
Member Function Documentation
| AuthComponent::action | ( | $ | action = ':controller/:action' |
) |
Returns the path to the ACO node bound to a controller/action.
- Parameters:
-
string $action Optional. The controller/action path to validate the user against. The current request action is used if none is specified.
- Returns:
- boolean ACO node path public
Definition at line 674 of file auth.php.
References Inflector::camelize(), and params().
Referenced by isAuthorized(), and startup().
| AuthComponent::allow | ( | ) |
Takes a list of actions in the current controller for which authentication is not required, or no parameters to allow all actions.
- Parameters:
-
string $action Controller action name string $action Controller action name string ... etc. public
| AuthComponent::deny | ( | ) |
Removes items from the list of allowed actions.
- Parameters:
-
string $action Controller action name string $action Controller action name string ... etc.
- See also:
- AuthComponent::allow() public
| & AuthComponent::getModel | ( | $ | name = null |
) |
Returns a reference to the model object specified, and attempts to load it if it is not found.
- Parameters:
-
string $name Model name (defaults to AuthComponent::$userModel)
- Returns:
- object A reference to a model object public
Definition at line 689 of file auth.php.
References ClassRegistry::init().
Referenced by identify(), and isAuthorized().
| AuthComponent::hashPasswords | ( | $ | data | ) |
| AuthComponent::identify | ( | $ | user = null, |
|
| $ | conditions = null | |||
| ) |
Identifies a user based on specific criteria.
- Parameters:
-
mixed $user Optional. The identity of the user to be validated. Uses the current user session if none specified. array $conditions Optional. Additional conditions to a find.
- Returns:
- array User record data, or null, if the user could not be identified. public
Definition at line 717 of file auth.php.
References $data, getModel(), password(), and user().
Referenced by login().
| AuthComponent::initialize | ( | &$ | controller | ) |
Initializes AuthComponent for use in the controller
- Parameters:
-
object $controller A reference to the instantiating controller object public
Definition at line 225 of file auth.php.
References Debugger::checkSessionKey(), App::import(), params(), and Configure::read().
| AuthComponent::isAuthorized | ( | $ | type = null, |
|
| $ | object = null, |
|||
| $ | user = null | |||
| ) |
Determines whether the given user is authorized to perform an action. The type of authorization used is based on the value of AuthComponent::$authorize or the passed $type param.
Types: 'controller' will validate against Controller::isAuthorized() if controller instance is passed in $object 'actions' will validate Controller::action against an AclComponent::check() 'crud' will validate mapActions against an AclComponent::check() array('model'=> 'name'); will validate mapActions against model $name::isAuthorize(user, controller, mapAction) 'object' will validate Controller::action against object::isAuthorized(user, controller, action)
- Parameters:
-
string $type Type of authorization mixed $object object, model object, or model name mixed $user The user to check the authorization of
- Returns:
- boolean True if $user is authorized, otherwise false public
Definition at line 416 of file auth.php.
References $authorize, $object, a(), action(), getModel(), mapActions(), params(), and user().
Referenced by startup().
| AuthComponent::login | ( | $ | data = null |
) |
Manually log-in a user with the given parameter data. The $data provided can be any data structure used to identify a user in AuthComponent::identify(). If $data is empty or not specified, POST data from Controller::$data will be used automatically.
After (if) login is successful, the user record is written to the session key specified in AuthComponent::$sessionKey.
- Parameters:
-
mixed $data User object
- Returns:
- boolean True on login success, false on failure public
Definition at line 568 of file auth.php.
References $data, and identify().
Referenced by startup().
| AuthComponent::logout | ( | ) |
Logs a user out, and returns the login action to redirect to.
- Parameters:
-
mixed $url Optional URL to redirect the user to after logout
- Returns:
- string AuthComponent::$loginAction
- See also:
- AuthComponent::$loginAction public
Definition at line 590 of file auth.php.
References Router::normalize().
| AuthComponent::mapActions | ( | $ | map = array() |
) |
Maps action names to CRUD operations. Used for controller-based authentication.
- Parameters:
-
array $map Actions to map public
Definition at line 544 of file auth.php.
Referenced by isAuthorized().
| AuthComponent::password | ( | $ | password | ) |
Hash a password with the application's salt value (as defined with Configure::write('Security.salt');
- Parameters:
-
string $password Password to hash
- Returns:
- string Hashed password public
Definition at line 810 of file auth.php.
References Security::hash().
Referenced by hashPasswords(), identify(), and startup().
| AuthComponent::redirect | ( | $ | url = null |
) |
If no parameter is passed, gets the authentication redirect URL.
- Parameters:
-
mixed $url Optional URL to write as the login redirect URL.
- Returns:
- string Redirect URL public
Definition at line 627 of file auth.php.
References $url, and Router::normalize().
Referenced by startup().
| AuthComponent::shutdown | ( | &$ | controller | ) |
| AuthComponent::startup | ( | &$ | controller | ) |
Main execution method. Handles redirecting of invalid users, and processing of login form data.
- Parameters:
-
object $controller A reference to the instantiating controller object public
Definition at line 256 of file auth.php.
References Controller::$components, $data, $loginAction, $object, $params, $url, Object::_stop(), action(), env(), hashPasswords(), isAuthorized(), login(), Router::normalize(), params(), password(), Configure::read(), redirect(), user(), and uses().
| AuthComponent::user | ( | $ | key = null |
) |
Get the current user from the session.
- Returns:
- array User record, or null if no user is logged in. public
Definition at line 603 of file auth.php.
Referenced by identify(), isAuthorized(), startup(), and validate().
| AuthComponent::validate | ( | $ | object, | |
| $ | user = null, |
|||
| $ | action = null | |||
| ) |
Validates a user against an abstract object.
- Parameters:
-
mixed $object The object to validate the user against. mixed $user Optional. The identity of the user to be validated. Uses the current user session if none specified. For valid forms of identifying users, see AuthComponent::identify(). string $action Optional. The action to validate against.
- See also:
- AuthComponent::identify()
- Returns:
- boolean True if the user validates, false otherwise. public
Member Data Documentation
| AuthComponent::$actionMap |
| AuthComponent::$authorize = false |
| AuthComponent::$components = array('Session', 'RequestHandler') |
| AuthComponent::$data = array() |
Definition at line 211 of file auth.php.
Referenced by hashPasswords(), identify(), login(), and startup().
| AuthComponent::$fields = array('username' => 'username', 'password' => 'password') |
| AuthComponent::$loginAction = null |
| AuthComponent::$object = null |
The documentation for this class was generated from the following file:
- 1.2.x.x/cake/libs/controller/components/auth.php