Adding Users
When adding a user, there are two required fields: username and password. The password must be given in clear text. BitAuth will handle the password hashing.
If you have customized user data, you only need to pass these fields to add_user() with all of the other data, BitAuth will put them in the appropriate table.
$this->bitauth->add_user($data, $require_activation = NULL)
$user = array(
'username' => 'testuser',
'password' => 'ABC123!'
);
$this->bitauth->add_user($user);
If you don't specify a groups attribute, the configuration value of default_group_id is used. For information about adding users to groups, see Assigning Groups or Adding Members.
$require_activation defaults to the configuration value of require_user_activation. How you handle user activation is completely up to you. If this value is TRUE, an activation code is generated and stored in the activation_code field.
$user = $this->bitauth->get_user_by_id(2);
if($user->active == FALSE)
{
echo $user->activation_code;
}
Adding Password Complexity Rules
In order to add your own password complexity rules, you need to make 3 changes.
In config/bitauth.php, you need to add a line to both $config['pwd_complexity'] and $config['pwd_complexity_chars']. pwd_complexity contains the required number of characters, and pwd_complexity_chars contains the regular expression to check for those characters.
/** * Optional password complexity options. Set a number for each to * require that many characters, or set to 0 to disable * Default: 1, 1, 0, 0 */ $config['pwd_complexity'] = array( 'uppercase' => 1, 'number' => 1, 'special' => 0, 'spaces' => 0, 'dash' => 1 ); /** * Which characters are included in each complexity check. Must be in * regex-friendly format. Using the Posix Collating Sequences should make these * language-independent, but are here in case you want to change them. */ $config['pwd_complexity_chars'] = array( 'uppercase' => '[[:upper:]]', 'number' => '[[:digit:]]', 'special' => '[[:punct:]]', 'spaces' => '\s', 'dash' => '-' );
Then, you just need to add a line to language/english/bitauth_lang.php, which contains the language line called when the rule fails validation.
/** * Password Complexity Labels */ $lang['bitauth_pwd_uppercase'] = 'Uppercase Letters'; $lang['bitauth_pwd_number'] = 'Numbers'; $lang['bitauth_pwd_special'] = 'Special Characters'; $lang['bitauth_pwd_spaces'] = 'Spaces'; $lang['bitauth_pwd_dash'] = 'Dashes';