$passwd = $oSpool->config['MESS_PASSWORD']; $passwdDec = G::decrypt($passwd, 'EMAILENCRYPT'); $auxPass = explode('hash:', $passwdDec); if (count($auxPass) > 1) { if (count($auxPass) == 2) { $passwd = $auxPass[1]; } else { array_shift($auxPass); $passwd = implode('', $auxPass); } } $oSpool->config['MESS_PASSWORD'] = $passwd; $oSpool->create(array('msg_uid' => '', 'app_uid' => '', 'del_index' => 0, 'app_msg_type' => 'TEST', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $data['USR_EMAIL'], 'app_msg_body' => $sBody, 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending', 'app_msg_attach' => '')); try { $oSpool->sendMail(); $rbacUser->update($aData); $user->update($aData); G::header("location: login.html"); G::SendTemporalMessage('ID_NEW_PASSWORD_SENT', "info"); } catch (phpmailerException $e) { G::header("location: login.html"); G::SendTemporalMessage(G::LoadTranslation('MISSING_OR_NOT_CONFIGURED_SMTP'), "warning", 'string'); } catch (Exception $e) { G::header("location: login.html"); G::SendTemporalMessage($e->getMessage(), "warning", 'string'); } } else { $msg = G::LoadTranslation('ID_USER') . ' ' . htmlentities($data['USR_USERNAME'], ENT_QUOTES, 'UTF-8') . ' ' . G::LoadTranslation('ID_IS_NOT_REGISTERED'); G::SendTemporalMessage($msg, "warning", 'string'); G::header('location: forgotPassword'); }
public function forgotPassword($httpData) { $this->setResponseType('json'); global $RBAC; require_once PATH_RBAC . "model/RbacUsers.php"; require_once 'classes/model/Users.php'; G::LoadClass("system"); $rbacUser = new RbacUsers(); $user = new Users(); try { $userData = $rbacUser->getByUsername($httpData->username); if (!$userData) { $msg = G::LoadTranslation('ID_USER') . ' <b>' . $httpData->username . '</b> ' . G::LoadTranslation('ID_IS_NOT_REGISTERED'); throw new Exception($msg); } if (trim($userData['USR_EMAIL']) != trim($httpData->email)) { $msg = G::LoadTranslation('ID_EMAIL_DOES_NOT_MATCH_FOR_USER') . ' <b>' . $httpData->username . '</b>'; throw new Exception($msg); } $newPass = G::generate_password(); $aData['USR_UID'] = $userData['USR_UID']; $aData['USR_PASSWORD'] = md5($newPass); $rbacUser->update($aData); $user->update($aData); $subject = G::loadTranslation('ID_PROCESSMAKER_FORGOT_PASSWORD_SERVICE'); $template = new TemplatePower(PATH_TPL . 'main/forgotPassword.tpl'); $template->prepare(); $template->assign('server', $_SERVER['SERVER_NAME']); $template->assign('serviceMsg', G::loadTranslation('ID_PROCESSMAKER_FORGOT_PASSWORD_SERVICE')); $template->assign('content', G::loadTranslation('ID_PASSWORD_CHANGED_SUCCESSFULLY')); $template->assign('passwd', $newPass); $template->assign('poweredBy', G::loadTranslation('ID_PROCESSMAKER_SLOGAN1')); $template->assign('versionLabel', G::loadTranslation('ID_VERSION')); $template->assign('version', System::getVersion()); $template->assign('visit', G::loadTranslation('ID_VISIT')); $template->assign('footer', ''); $body = $template->getOutputContent(); G::sendMail('', 'ProcessMaker Service', $httpData->email, $subject, $body); $result->success = true; $result->message = G::LoadTranslation('ID_NEW_PASSWORD_SENT'); } catch (Exception $e) { $result->success = false; $result->message = $e->getMessage(); } return $result; }