Example #1
0
 /**
 	Create a new weeAuthDbTable object and stores the paramters.
 
 	Parameters:
 		* db:					The weeDatabase object to authenticate against.
 		* table:				The table containing the credentials to authenticate against.
 		* identifier_field:		The field containing the identifiers.
 		* password_field:		The field containing the passwords hashed with 'password_treatment'.
 		* password_treatment:	The callback applied to each passwords stored in the 'password_field' field. Defaults to 'sha1'.
 		* hash_treatment:		The callback to use to hash passwords stored client-side. Defaults to 'sha1'.
 
 	@param $aParams List of parameters to authenticate against.
 */
 public function __construct($aParams = array())
 {
     if (empty($aParams['db'])) {
         $aParams['db'] = weeApp()->db;
     }
     is_object($aParams['db']) && $aParams['db'] instanceof weeDatabase or burn('InvalidArgumentException', sprintf(_WT('Parameter "%s" must be an instance of "%s".'), 'db', 'weeDatabase'));
     empty($aParams['table']) and burn('InvalidArgumentException', _WT('You must provide a parameter "table" containing the name of the credentials table in your database.'));
     empty($aParams['identifier_field']) and burn('InvalidArgumentException', _WT('You must provide a parameter "identifier_field" containing the name of the field for the identifiers.'));
     empty($aParams['password_field']) and burn('InvalidArgumentException', _WT('You must provide a parameter "password_field" containing the name of the field for the passwords.'));
     if (empty($aParams['password_treatment'])) {
         $aParams['password_treatment'] = 'sha1';
     } else {
         is_callable($aParams['password_treatment']) or burn('InvalidArgumentException', sprintf(_WT('The "%s" parameter must be a valid callback.'), 'password_treatment'));
     }
     parent::__construct($aParams);
 }
Example #2
0
 /**
 	Create a new weeAuthLDAP object and store the paramters.
 
 	Parameters:
 		* ldap: The weeLDAP object getted after authentication to the LDAP server.
 		* base_dn: The base DN for making search.
 		* hash_treatment: The callback to use to hash passwords stored client-side. Defaults to 'sha1'.
 
 	@param $aParams List of parameters to authenticate against.
 */
 public function __construct($aParams = array())
 {
     empty($aParams['ldap']) and burn('InvalidArgumentException', _WT('You must provide a parameter "ldap" containing the instance of weeLDAP.'));
     empty($aParams['base_dn']) and burn('InvalidArgumentException', _WT('You must provide a parameter "base_dn" containing the base DN.'));
     parent::__construct($aParams);
 }