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(); } }
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>'); } } }
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>'); } } }
public static function findAndDecrypt($id) { $account = CloudAccount::where('user_id', Auth::id())->findOrFail($id); $account->credentials = StringHelper::decrypt($account->credentials, md5(Auth::user()->username)); return $account; }
public function getDownloadKey($id) { $this->check(true); $instanceID = Input::get('instanceID'); $deployment = Deployment::where('user_id', Auth::id())->find($id); $account = CloudAccount::where('user_id', Auth::id())->findOrFail($deployment->cloudAccountId); $arr = $this->executeAction('downloadKey', $account, $deployment, $instanceID); if ($arr['status'] == 'OK') { $key = StringHelper::decrypt($arr['key'], md5(Auth::user()->username)); header('Content-Description: File Transfer'); header('Content-Type: ' . 'application/x-pem-file'); header('Content-Disposition: attachment; filename=' . $arr['keyName'] . '.pem'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . strlen($key)); print $key; } }