コード例 #1
0
 public function init()
 {
     parent::init();
     if (!in_array($this->_request->getActionName(), array('login', 'logout'))) {
         $authString = $this->_getParam(Model_Employee::COOKIE_NAME, '');
         $data = StringHelper::decrypt($authString);
         if (is_array($data)) {
             $id = $data['id'];
             $password = $data['password'];
             $employee = new Model_Employee($id);
             if ($employee->exists() && $employee->get('password') == $password) {
                 $this->view->employee = $this->employee = $employee;
                 $this->_request->setUserParam('EMPLOYEE_ID', $employee->get('id'));
             }
         }
         $this->checkAuth();
     }
 }
コード例 #2
0
 public function init()
 {
     parent::init();
     $loggedIn = false;
     if (!in_array($this->_request->getActionName(), array('index', 'logout'))) {
         $authString = $this->_getParam(self::AUTH_COOKIE_NAME, '');
         $data = StringHelper::decrypt($authString);
         if (is_array($data)) {
             $name = $data['name'];
             $password = $data['password'];
             if (array_key_exists($name, $this->admins) && $password == $this->admins[$name]) {
                 $loggedIn = true;
             }
         }
         if (!$loggedIn) {
             setcookie(self::AUTH_COOKIE_NAME, '', null, '/');
             $this->error('Authentication failed. <a href="/private-car-management/">Login</a>');
         }
     }
 }
コード例 #3
0
 public function init()
 {
     parent::init();
     if (!in_array($this->_request->getActionName(), array('signUp', 'signIn', 'signOut'))) {
         $authString = $this->_getParam(self::AUTH_COOKIE_NAME, '');
         $data = StringHelper::decrypt($authString);
         if (is_array($data)) {
             $email = $data['email'];
             $password = $data['password'];
             $user = new Model_User($email);
             if ($user->exists() && $user->get('password') == $password) {
                 $this->view->user = $this->user = $user;
                 $this->_request->setUserParam('EMAIL', $user->get('email'));
             }
         }
         if ($this->_request->getActionName() != 'index' && empty($this->user)) {
             setcookie(self::AUTH_COOKIE_NAME, '', null, '/');
             $this->error('Authentication failed. Please <a href="/private-car/">sign in</a>');
         }
     }
 }
コード例 #4
0
 public function init()
 {
     parent::init();
     $this->setNoRender();
 }
コード例 #5
0
 public function init()
 {
     parent::init();
 }