public function actionRecover($key = null)
 {
     if ($key) {
         $user = User::objects()->get(['activation_key' => $key]);
         if ($user === null) {
             echo $this->json(['status' => false, 'error' => 'User not found']);
             $this->end();
         }
         $user->password = '';
         $user->save(['password']);
         $form = new ChangePasswordForm();
         $form->setModel($user);
         $r = $this->getRequest();
         if ($r->getIsPost() && $form->populate($_POST)->isValid() && $form->save()) {
             echo $this->json(['status' => true, 'message' => UserModule::t('Password changed')]);
             $this->end();
         } else {
             echo $this->json(['errors' => $form->getJsonErrors()]);
             $this->end();
         }
     } else {
         $form = new RecoverForm();
         if ($form->populate($_POST)->isValid() && $form->send()) {
             echo $this->json(['status' => true]);
         } else {
             echo $this->json(['errors' => $form->getJsonErrors()]);
         }
     }
 }
Beispiel #2
0
 public function actionChangePassword($pk)
 {
     $model = User::objects()->get(['pk' => $pk]);
     if ($model === null) {
         $this->error(404);
     }
     $form = new ChangePasswordForm(['model' => $model]);
     $request = $this->getRequest();
     if ($request->getIsPost()) {
         if ($form->populate($_POST, $_FILES)->isValid()) {
             if ($form->save()) {
                 $this->afterCreate($form);
                 $request->flash->success('Данные успешно сохранены');
                 $next = $this->getNextRoute($_POST, $form);
                 if ($next) {
                     $request->redirect($next);
                 } else {
                     $request->refresh();
                 }
             } else {
                 $request->flash->error('При сохранении данных произошла ошибка, пожалуйста попробуйте выполнить сохранение позже или обратитесь к разработчику проекта, или вашему системному администратору');
             }
         } else {
             $request->flash->warning('Пожалуйста укажите корректные данные');
         }
     }
     echo $this->render($this->getTemplate('change_password.html'), ['model' => $model, 'form' => $form, 'breadcrumbs' => $this->fetchBreadcrumbs($model, 'change_password')]);
 }
 public function actionChangePassword()
 {
     $user = Mindy::app()->getUser();
     $form = new ChangePasswordForm();
     $form->setModel($user);
     $r = $this->getRequest();
     if ($r->getIsPost() && $form->populate($_POST)->isValid() && $form->save()) {
         echo $this->json(['status' => true, 'message' => UserModule::t('Password changed')]);
         $this->end();
     } else {
         echo $this->json(['errors' => $form->getJsonErrors()]);
         $this->end();
     }
 }
 public function actionChangepassword()
 {
     $model = Mindy::app()->user;
     if ($this->getModule()->userList) {
         $this->addBreadcrumb(UserModule::t("Users"), Mindy::app()->urlManager->reverse('user:list'));
     }
     $this->addBreadcrumb($model, $model->getAbsoluteUrl());
     $this->addBreadcrumb(UserModule::t("Change password"));
     $form = new ChangePasswordForm(['model' => $model]);
     if ($this->getRequest()->isPost && $form->populate($_POST)->isValid() && $form->save()) {
         $this->getRequest()->flash->success(UserModule::t('Password changed'));
         $this->getRequest()->redirect('user:login');
     }
     echo $this->render('user/change_password.html', ['form' => $form, 'model' => $model]);
 }
 public function actionActivate($key)
 {
     $model = User::objects()->filter(['activation_key' => $key])->get();
     if ($model === null) {
         $this->error(404);
     }
     if ($model->activation_key === $key) {
         $form = new ChangePasswordForm(['model' => $model]);
         if ($this->getRequest()->isPost && $form->populate($_POST)->isValid() && $form->save()) {
             $this->getRequest()->flash->success(UserModule::t('Password changed'));
             $this->getRequest()->redirect('user:login');
         } else {
             echo $this->render('user/recover_change_password.html', ['form' => $form, 'model' => $model, 'key' => $key]);
         }
     } else {
         echo $this->render('user/change_password_incorrect.html');
     }
 }
 public function actionChangepassword($id)
 {
     $auth = Mindy::app()->auth;
     if ($auth->isGuest) {
         $this->r->redirect(Mindy::app()->homeUrl);
     }
     $model = User::objects()->filter(['pk' => $id])->get();
     if ($model === null) {
         $this->error(404);
     }
     $admin = new UserAdmin();
     $this->addBreadcrumb(Text::mbUcfirst($admin->getVerboseName()), Mindy::app()->urlManager->reverse('admin:list', ['module' => User::getModuleName(), 'adminClass' => $admin->classNameShort()]));
     $this->addBreadcrumb((string) $model, Mindy::app()->urlManager->reverse('admin:update', ['module' => User::getModuleName(), 'adminClass' => $admin->classNameShort(), 'id' => $id]));
     $this->addBreadcrumb(UserModule::t('Change password'));
     $form = new ChangePasswordForm(['model' => $model]);
     if ($this->r->isPost && $form->populate($_POST)->isValid() && $form->save()) {
         $this->r->flash->success(UserModule::t('Password changed'));
         $this->r->http->refresh();
     }
     echo $this->render('admin/changepassword.html', ['model' => $model, 'form' => $form]);
 }