Ejemplo n.º 1
0
 public function actionGetNewPassword()
 {
     $request = CStaffManager::getPasswordRecoveryRequest(CRequest::getString("id"));
     if (is_null($request)) {
         $this->renderView("_acl_manager/no_recovery_request.tpl");
         return true;
     }
     if (!$request->isActive()) {
         $this->renderView("_acl_manager/request_used.tpl");
         return true;
     }
     $user = CStaffManager::getUser($request->credential);
     if (is_null($user)) {
         $this->renderView("_acl_manager/no_recovery_request.tpl");
         return true;
     }
     // новый пароль
     $password = substr(md5(time()), 0, 7);
     $user->password = md5($password);
     $user->save();
     // запрос использован
     $request->active = 0;
     $request->save();
     // уведомляем пользователя
     if (!is_null(CNotificationManager::getTemplate("newPasswordSent"))) {
         $message = CNotificationManager::getTemplate("newPasswordSent")->createNotification();
         $message->appendLine("Логин: " . $user->getLogin());
         $message->appendLine("Пароль: " . $password);
         $message->email($user->getPerson());
     }
     $this->renderView("_acl_manager/request_processed.tpl");
 }