/** * Reset an user's password * * @param array $userInfo * @return boolean|string */ public function resetUserPassword(array $userInfo) { try { $this->adapter->getDriver()->getConnection()->beginTransaction(); $newPassword = $this->generateRandString(); $update = $this->update()->table('user_list')->set(['password' => $this->generatePassword($newPassword), 'activation_code' => null, 'date_edited' => date('Y-m-d')])->where(['user_id' => $userInfo['user_id']]); $statement = $this->prepareStatementForSqlObject($update); $statement->execute(); // clear a cache $this->removeUserCache($userInfo['user_id']); $this->adapter->getDriver()->getConnection()->commit(); } catch (Exception $e) { $this->adapter->getDriver()->getConnection()->rollback(); ApplicationErrorLogger::log($e); return $e->getMessage(); } // fire the user password reset event UserEvent::fireUserPasswordResetEvent($userInfo['user_id'], $userInfo, $newPassword); return true; }