/** * 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; }
<span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="<?php echo Config::get('URL'); ?> "><?php echo Config::get('APP_NAME'); ?> </a> </div> <div id="navbar" class="navbar-collapse collapse"> <?php if (Session::userIsLoggedIn()) { ?> <ul class="nav navbar-nav"> <li class="dropdown"> <a href="<?php echo Config::get('URL'); ?> service/all/" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Services<span class="caret"></span></a> <ul class="dropdown-menu" role="menu"> <li><a href="<?php echo Config::get('URL'); ?> service/all/">Manage Services</a></li> <li><a href="<?php echo Config::get('URL'); ?>
/** * Returns the current state of the user's login * * @return bool user's login status */ public static function isUserLoggedIn() { return Session::userIsLoggedIn(); }
/** * Set the new password * Please note that this happens while the user is not logged in. The user identifies via the data provided by the * password reset link from the email, automatically filled into the <form> fields. See verifyPasswordReset() * for more. Then (regardless of result) route user to index page (user will get success/error via feedback message) * POST request ! * TODO this is an _action */ public function setNewPassword() { if (Session::userIsLoggedIn()) { PasswordResetModel::setNewPassword(Request::post('user_name'), Request::post('user_password_reset_hash'), Request::post('user_password_new'), Request::post('user_password_repeat')); $user_name = Session::get('user_name'); $this->View->render('login/set_new_password', array('user_name' => $user_name)); } else { Redirect::to('login/index'); } }