예제 #1
0
 public function actionLogin()
 {
     $form = new LoginForm();
     if ($this->r->isPost && $form->populate($_POST)->isValid() && $form->login()) {
         if ($this->r->isAjax) {
             echo $this->json(array('status' => 'success', 'title' => UserModule::t('You have successfully logged in to the site')));
         } else {
             $this->r->redirect('admin:index');
         }
     }
     $data = ['form' => $form];
     if ($this->r->isAjax) {
         echo $this->json(['content' => $this->render('admin/_login.html', $data)]);
     } else {
         echo $this->render('admin/login.html', $data);
     }
 }
예제 #2
0
 public function actionLogin()
 {
     $request = $this->getRequest();
     $app = Mindy::app();
     if ($app->getUser()->getIsGuest() === false) {
         $request->redirect('user:profile');
     }
     $this->addBreadcrumb(UserModule::t("Login"));
     $form = new LoginForm();
     if ($request->getIsPost() && $form->populate($_POST)->isValid() && $form->login()) {
         $this->redirectNext();
         if ($request->getIsAjax()) {
             echo $this->json(['status' => 'success', 'title' => UserModule::t('You have successfully logged in to the site')]);
             Mindy::app()->end();
         } else {
             $request->redirect('user:profile');
         }
     }
     echo $this->render('user/login.html', ['form' => $form]);
 }