Example #1
0
/**
 * Verify a login using a FIM's database.
 *
 * @param array user - The userdata array.
 * @param string password - The submitted password (usually via a form).

 * @return bool - Whether or not the user is valid.
 * @author Joseph Todd Parsons <*****@*****.**>
*/
function processVanilla($user, $password)
{
    if (!$user['userId']) {
        // The user does not exist.
        return false;
    } else {
        if (fim_generatePassword($password, $user['passwordSalt'], $user['passwordSaltNum'], 0) === $user['password']) {
            // The password is correct.
            return true;
        } else {
            // The password is not correct.
            return false;
        }
    }
}
Example #2
0
 } else {
     $encryptSalt = '';
     $encryptSaltNum = 0;
 }
 $passwordSalt = fim_generateSalt();
 // Generate a random salt.
 // Encrypt Sent Password
 switch ($request['passwordEncrypt']) {
     case 'plaintext':
         $password = fim_generatePassword($request['password'], $passwordSalt, $encryptSaltNum, 0);
         break;
     case 'sha256':
         $password = fim_generatePassword($request['password'], $passwordSalt, $encryptSaltNum, 1);
         break;
     case 'sha256-salt':
         $password = fim_generatePassword($request['password'], $passwordSalt, $encryptSaltNum, 2);
         break;
     default:
         $errStr = 'badEncryption';
         $errDesc = 'The password encryption specified is not supported.';
         $continue = false;
         break;
 }
 // Generate Value for User Privs
 $userPrivs = 16;
 if ($config['userRoomCreation']) {
     $userPrivs += 32;
 }
 if ($config['userPrivateRoomCreation']) {
     $userPrivs += 64;
 }