public function getAuthorObj() { if (isset($this->authorObj)) { return $this->authorObj; } else { $this->authorObj = User::getObjById($this->author); return $this->authorObj; } }
public function index() { if (Session::loggedIn()) { $this->template("header", ["title" => App::NAME, "subtitle" => App::TAGLINE, "categories" => ArticleCategory::getObjsAll()]); // $this->template("hero", ["title" => "News"]); $this->view("account/index", ["user" => User::getObjByEmail(Session::getUsername())]); //$this->jq("account/index"); $this->template("footer"); } else { header("Location: /"); } }
public function login() { $user = User::getObjByEmail($_POST["email"]); if (isset($user) && password_verify($_POST["password"], $user->getPassword())) { Session::setUsername($user->getEmail()); $user->setAuthKey(String::generateRandomString()); $user->save(); if (isset($_POST['remember-me'])) { Session::setRememberMeFlag(); Cookie::setRememberMeCookies($user->getEmail(), $user->getAuthKey()); } header("Location: /"); } else { header("Location: /auth"); } }
public function __construct() { if (ENVIRONMENT == 'development') { new GenModels(); } session_start(); $this->router = new Router(); if (!Session::loggedIn() && null !== Cookie::getUsername() && null !== Cookie::getAuthKey()) { $user = User::getObjByAuthKey(Cookie::getAuthKey()); if (isset($user) && $user->getEmail() == Cookie::getUsername()) { Session::setUsername($user->getEmail()); Session::setRememberFlag(true); Cookie::setRememberMeCookies($user->getEmail(), $user->getAuthKey()); } } }