public function action_login() { $worker = new Users(); $worker->login = $_POST['login']; $worker->password = $_POST['pass']; // Проверяем соответствие "пароль/логин" $dataArray = $worker->findByColumn('login', $worker->login); foreach ($dataArray as $data) { $login = $data['Login']; $password = $data['Password']; } // Все совпало - стартуем сессию if ($login === $worker->login && $password === $worker->password) { session_start(); $_SESSION['user'] = $worker->login; header('Location: http://vesta-clubs.ru/index.php'); } else { $this->error = 'Не верные данные!'; include_once __DIR__ . '/../views/login_views.php'; // header('Location: http://vesta-clubs.ru/index.php'); } }
public function index() { $authProvider = new GoogleAuthProvider($_GET, ["client_id" => $this->config["GOOGLE_OAUTH_ID"], "client_secret" => $this->config["GOOGLE_OAUTH_SECRET"], "redirect_uri" => $this->config["REDIRECT_URI"]]); $oauth = new OAuth($authProvider, $_GET); $check = $oauth->check(); if ($check === true) { $email = $authProvider->getEmail(); /** @var Users $user */ $users = Users::getByField("email", $email); if (count($users) == 0) { echo $this->accessDenied(); return; } $user = $users[0]; $this->session->data = json_encode(["userId" => $user->id]); $this->session->save(); $this->sessionData = $this->session->data; header("Location: /kritbit"); } else { header("Location: " . $check); } }
protected function isUserLoggedIn() { if (isset($_COOKIE["session"])) { $validSession = Sessions::getByField("sessionid", $_COOKIE["session"]); if ($validSession) { try { $this->session = $validSession[0]; $this->sessionData = json_decode($this->session->data); if ($this->sessionData == null) { return false; } $this->user = \application\models\Users::getByField("id", $this->sessionData->userId)[0]; return true; } catch (\Exception $e) { return false; } } else { return false; } } return false; }