public function resetPassword($newPassword, $userId, $ip) { $salt = \Hub\Util::createAlnumString(); $newPassword = sha1($newPassword . $salt); $data = array('password' => $newPassword, 'salt' => $salt, 'reset_ip' => $ip, 'date_reset' => date('Y-m-d H:i:s')); return $this->update($data, array('id' => $userId)); }
/** * Reset an existing api user password. * * @param string $org * @param string $username * @param string $password * @return int */ public function resetPassword($org, $username, $password) { if (($row = $this->fetchBy(['org' => $org, 'username' => $username])) !== false) { return false; } $salt = \Hub\Util::createAlnumString(128); $password = sha1($password . $salt); $data = array('password' => $password, 'salt' => $salt); return (int) $this->update($data, array('id' => $row['id'])); }
/** * Vertify the incoming request for common malicious characters. * * @param array $request | key - value request pair * @param mixed $required | required keys in $request * @param array $excludes | excluded in character check(preg_match below) - USE WITH CAUTION - * @return boolean */ protected function isValid(array $data, $required = array(), array $excludes = array()) { return \Hub\Util::isValidRequest($data, $required, $excludes); }