예제 #1
0
 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()]);
         }
     }
 }
예제 #2
0
 public function actionIndex()
 {
     $this->addBreadcrumb(UserModule::t("Recover password"));
     $form = new RecoverForm();
     if ($this->getRequest()->isPost) {
         if ($form->populate($_POST)->isValid() && $form->send()) {
             $this->getRequest()->flash->success(UserModule::t("Message was sended to your email"));
             echo $this->render('user/recover_form_success.html');
             Mindy::app()->end();
         } else {
             $this->getRequest()->flash->error(UserModule::t("An error has occurred. Please try again later."));
         }
     }
     echo $this->render('user/recover_form.html', ['form' => $form]);
 }