/** * Construct the (base) controller. This happens when a real controller is constructed, like in * the constructor of IndexController when it says: parent::__construct(); */ function __construct(LoggerInterface $logger = null) { // always initialize a session Session::init(); // user is not logged in but has remember-me-cookie ? then try to login with cookie ("remember me" feature) if (!Session::userIsLoggedIn() and Request::cookie('remember_me')) { header('location: ' . Config::get('URL') . 'login/loginWithCookie'); } // create a view object to be able to use it inside a controller, like $this->View->render(); $this->View = new View(); //initialize the logger object $this->logger = $logger; }
/** * The real login process: The user's data is written into the session. * Cheesy name, maybe rename. Also maybe refactoring this, using an array. * * @param $user_id * @param $user_name * @param $user_email * @param $user_account_type */ public static function setSuccessfulLoginIntoSession($user_id, $user_name, $user_email, $user_account_type) { Session::init(); Session::set('user_id', $user_id); Session::set('user_name', $user_name); Session::set('user_email', $user_email); Session::set('user_account_type', $user_account_type); Session::set('user_provider_type', 'DEFAULT'); // get and set avatars //Session::set('user_avatar_file', AvatarModel::getPublicUserAvatarFilePathByUserId($user_id)); //Session::set('user_gravatar_image_url', AvatarModel::getGravatarLinkByEmail($user_email)); // finally, set user as logged-in Session::set('user_logged_in', true); }