public function postShowLoginPage()
 {
     if (!$this->signer->validateSignature($_POST['_token'])) {
         header('HTTP/1.0 400 Bad Request');
         exit;
     }
     $okay = true;
     $email = $_REQUEST['email'];
     $password = $_REQUEST['password'];
     // look up the user
     $user = User::where('email', '=', $email)->first();
     if ($user != null) {
         // validate credentials
         if (!password_verify($password, $user->password)) {
             $okay = false;
         }
     } else {
         $okay = false;
     }
     if ($user->active == 0) {
         $okay = false;
     }
     // if valid, log them in
     if ($okay) {
         $_SESSION['user'] = $user;
         header("Location: /");
         exit;
     } else {
         // if not vaild, redirect to login page
         $_SESSION['msg'] = ["Invalid login!"];
         echo $this->blade->render("login", ['signer' => $this->signer]);
         unset($_SESSION['msg']);
         exit;
     }
 }
 /**
  * Handle posted login data
  */
 public function postShowLoginPage()
 {
     if (!$this->signer->validateSignature($this->request->post['_token'])) {
         header('HTTP/1.0 400 Bad Request');
         exit;
     }
     $rules = ['email' => 'email|min:3', 'password' => 'min:3'];
     $validator = new Validator($this->request, $this->response, $this->session);
     $valid = $validator->validate($rules, '/login');
     if ($valid) {
         $okay = true;
         $email = $this->request->post['email'];
         $password = $this->request->post['password'];
         $user = User::where('email', '=', $email)->first();
         if ($user != null) {
             if (!password_verify($password, $user->password)) {
                 $okay = false;
             }
         } else {
             $okay = false;
         }
         if ($user && $user->active == 0) {
             $okay = false;
         }
         if ($okay) {
             $this->session->put('user', $user);
             $this->response->withMessage("Successfully logged in")->redirectTo("/");
         } else {
             $this->session->put('_error', 'Invalid login!!');
             $this->response->redirectTo('/login');
         }
     }
 }
 public function postShowLoginPage()
 {
     if (!$this->signer->validateSignature($_POST['_token'])) {
         header('HTTP/1.0 400 Bad Request');
         exit;
     }
     $okay = true;
     $activated = true;
     $email = $_REQUEST['email'];
     $password = $_REQUEST['password'];
     // look up the user based on email
     $user = User::where('email', '=', $email)->first();
     if ($user != null) {
         //validate credentials
         if (!password_verify($password, $user->password)) {
             $okay = false;
         }
     } else {
         $okay = false;
     }
     // if user is not yet activated through email link
     // deny access to account through flags
     if ($okay == true && $user->active == 0) {
         $okay = false;
         $activated = false;
     }
     // if user is valid, log them in
     if ($okay) {
         $_SESSION['user'] = $user;
         header("Location: /");
         exit;
     } else {
         // if user is not vaild, check to see if it's
         // because their account isn't activated
         if (!$activated) {
             $_SESSION['msg'] = ["Invalid login.  You have not yet activated your account.  Please check your email."];
         } else {
             // if they don't have an account, activated
             // or not, let them know
             $_SESSION['msg'] = ["Invalid login."];
         }
         // if not valid for whatever reason, redirect
         // to login page and display appropriate
         // error message
         echo $this->blade->render('login', ['signer' => $this->signer]);
         unset($_SESSION['msg']);
         exit;
     }
 }
 public function postShowLoginPage()
 {
     //for csrf
     if (!$this->signer->validateSignature($_POST['_token'])) {
         header('HTTP/1.0 400 Bad Request');
         exit;
     }
     //echo "posted";
     $okay = true;
     $email = $_REQUEST['email'];
     $pass = $_REQUEST['password'];
     $user = User::where('email', '=', $email)->first();
     if ($user != null) {
         //validate password
         if (!password_verify($pass, $user->password)) {
             $okay = false;
         }
     } else {
         $okay = false;
     }
     if ($user->active == 0) {
         $okay = false;
     }
     if ($okay) {
         $_SESSION['user'] = $user;
         header("Location: /");
         exit;
         //dd(LoggedIn::user());
     } else {
         $_SESSION['msg'] = ["Invalid Login"];
         //echo $this->blade->render('login');
         echo $this->blade->render("login", ['signer' => $this->signer]);
         unset($_SESSION['msg']);
         exit;
     }
 }