public function loginAction(Request $request)
 {
     $login = new LoginModel($request);
     if ($request->isPost()) {
         if ($login->isValid()) {
             if ($login->getUser()) {
                 $user = array('user' => $login->getUser()[0]['username'], 'id' => $login->getUser()[0]['id']);
                 Session::set('user', $user);
                 Session::setFlash(__t('logged_in'));
                 $this->redirect("/");
             } else {
                 Session::setFlash(__t('login_or_password_incorrect'));
             }
         } else {
             Session::setFlash(__t('fill_fields'));
         }
     }
     $img_default_url = 'Webroot/uploads/images/' . Config::get('default_img');
     $args = array('login' => $login, 'img' => $img_default_url);
     return $this->render($args);
 }
 public function loginAction(Request $request)
 {
     $msg = $request->get('msg');
     $login = new LoginModel($request);
     if ($request->isPost()) {
         if ($login->isValid()) {
             if ($login->getUser()) {
                 $user = array('user' => $login->getUser()[0]['username'], 'id' => $login->getUser()[0]['id']);
                 Session::set('user', $user);
                 //$msg = 'ok';
                 $this->redirect("index.php?id=1&msg=You have been logged in");
             } else {
                 $msg = 'You are not registered.<a href="index.php?rout=index/register&id=5">Register</a>';
             }
         } else {
             $msg = 'Please fill in fields ';
         }
     }
     $args = array('login' => $login, 'msg' => $msg);
     return $this->render('login', $args);
 }