public static function parseLogin() { $email = $_POST['email']; $senha = $_POST['senha']; $temp = DBController::init(); $usuarios = $temp->db_user; $all = iterator_to_array($usuarios->find(["email" => $email, "senha" => $senha])); if ($all != array()) { foreach ($all as $key => $value) { $obj = array('token' => $key, 'nome' => $value['nome'], 'email' => $value['email'], 'senha' => $value['senha'], 'status' => true, 'message' => "Login feito com sucesso"); } SessionController::set("user", $obj); } else { $obj = array('email' => $email, 'senha' => $senha, 'status' => false, 'message' => "Email ou senha incorretos", 'status' => false); } RotaController::res($obj); }
public function login($email = null, $user_password = null) { //check if email exists in data base //check if password is set if ($this->find_by_email($email) && $user_password) { $this->_email = $email; $this->_password = $user_password; $this->_hash = $this->_data['password']; if (Encryption::checkPassword($this->_password, $this->_hash)) { //set the data in a session. $session = new SessionController(); $session->set('user_session', array("user_id" => $this->_data['id'], "name" => $this->_data['name'] . " " . $this->_data['lastname'])); return true; // RedirectController::to("/kortingennu/"); } } return false; }