parent
084203f0cf
commit
7b792c9541
|
@ -29,15 +29,15 @@ class Application extends b8\Application
|
||||||
|
|
||||||
// Inlined as a closure to fix "using $this when not in object context" on 5.3
|
// Inlined as a closure to fix "using $this when not in object context" on 5.3
|
||||||
$validateSession = function () {
|
$validateSession = function () {
|
||||||
if (!empty($_SESSION['user_id'])) {
|
if (!empty($_SESSION['phpci_user_id'])) {
|
||||||
$user = b8\Store\Factory::getStore('User')->getByPrimaryKey($_SESSION['user_id']);
|
$user = b8\Store\Factory::getStore('User')->getByPrimaryKey($_SESSION['phpci_user_id']);
|
||||||
|
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$_SESSION['user'] = $user;
|
$_SESSION['phpci_user'] = $user;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($_SESSION['user_id']);
|
unset($_SESSION['phpci_user_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -52,7 +52,7 @@ class Application extends b8\Application
|
||||||
$response->setResponseCode(401);
|
$response->setResponseCode(401);
|
||||||
$response->setContent('');
|
$response->setContent('');
|
||||||
} else {
|
} else {
|
||||||
$_SESSION['login_redirect'] = substr($request->getPath(), 1);
|
$_SESSION['phpci_login_redirect'] = substr($request->getPath(), 1);
|
||||||
$response = new RedirectResponse($response);
|
$response = new RedirectResponse($response);
|
||||||
$response->setHeader('Location', PHPCI_URL.'session/login');
|
$response->setHeader('Location', PHPCI_URL.'session/login');
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ class Controller extends \b8\Controller
|
||||||
|
|
||||||
protected function requireAdmin()
|
protected function requireAdmin()
|
||||||
{
|
{
|
||||||
if (!$_SESSION['user']->getIsAdmin()) {
|
if (!$_SESSION['phpci_user']->getIsAdmin()) {
|
||||||
throw new ForbiddenException('You do not have permission to do that.');
|
throw new ForbiddenException('You do not have permission to do that.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ class BuildController extends \PHPCI\Controller
|
||||||
*/
|
*/
|
||||||
public function delete($buildId)
|
public function delete($buildId)
|
||||||
{
|
{
|
||||||
if (empty($_SESSION['user']) || !$_SESSION['user']->getIsAdmin()) {
|
if (empty($_SESSION['phpci_user']) || !$_SESSION['phpci_user']->getIsAdmin()) {
|
||||||
throw new \Exception('You do not have permission to do that.');
|
throw new \Exception('You do not have permission to do that.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ class PluginController extends \PHPCI\Controller
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
if (!$_SESSION['user']->getIsAdmin()) {
|
if (!$_SESSION['phpci_user']->getIsAdmin()) {
|
||||||
throw new \Exception('You do not have permission to do that.');
|
throw new \Exception('You do not have permission to do that.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ class PluginController extends \PHPCI\Controller
|
||||||
|
|
||||||
public function remove()
|
public function remove()
|
||||||
{
|
{
|
||||||
if (!$_SESSION['user']->getIsAdmin()) {
|
if (!$_SESSION['phpci_user']->getIsAdmin()) {
|
||||||
throw new \Exception('You do not have permission to do that.');
|
throw new \Exception('You do not have permission to do that.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ class PluginController extends \PHPCI\Controller
|
||||||
|
|
||||||
public function install()
|
public function install()
|
||||||
{
|
{
|
||||||
if (!$_SESSION['user']->getIsAdmin()) {
|
if (!$_SESSION['phpci_user']->getIsAdmin()) {
|
||||||
throw new \Exception('You do not have permission to do that.');
|
throw new \Exception('You do not have permission to do that.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,8 @@ class ProjectController extends \PHPCI\Controller
|
||||||
throw new NotFoundException('Project with id: ' . $projectId . ' not found');
|
throw new NotFoundException('Project with id: ' . $projectId . ' not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$build = $this->buildService->createBuild($project, null, urldecode($branch), $_SESSION['user']->getEmail());
|
$email = $_SESSION['phpci_user']->getEmail();
|
||||||
|
$build = $this->buildService->createBuild($project, null, urldecode($branch), $email);
|
||||||
|
|
||||||
header('Location: '.PHPCI_URL.'build/view/' . $build->getId());
|
header('Location: '.PHPCI_URL.'build/view/' . $build->getId());
|
||||||
exit;
|
exit;
|
||||||
|
@ -119,7 +120,7 @@ class ProjectController extends \PHPCI\Controller
|
||||||
*/
|
*/
|
||||||
public function delete($projectId)
|
public function delete($projectId)
|
||||||
{
|
{
|
||||||
if (!$_SESSION['user']->getIsAdmin()) {
|
if (!$_SESSION['phpci_user']->getIsAdmin()) {
|
||||||
throw new ForbiddenException('You do not have permission to do that.');
|
throw new ForbiddenException('You do not have permission to do that.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +224,7 @@ class ProjectController extends \PHPCI\Controller
|
||||||
*/
|
*/
|
||||||
public function edit($projectId)
|
public function edit($projectId)
|
||||||
{
|
{
|
||||||
if (!$_SESSION['user']->getIsAdmin()) {
|
if (!$_SESSION['phpci_user']->getIsAdmin()) {
|
||||||
throw new ForbiddenException('You do not have permission to do that.');
|
throw new ForbiddenException('You do not have permission to do that.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class SessionController extends \PHPCI\Controller
|
||||||
$user = $this->userStore->getByEmail($this->getParam('email'));
|
$user = $this->userStore->getByEmail($this->getParam('email'));
|
||||||
|
|
||||||
if ($user && password_verify($this->getParam('password', ''), $user->getHash())) {
|
if ($user && password_verify($this->getParam('password', ''), $user->getHash())) {
|
||||||
$_SESSION['user_id'] = $user->getId();
|
$_SESSION['phpci_user_id'] = $user->getId();
|
||||||
header('Location: ' . $this->getLoginRedirect());
|
header('Location: ' . $this->getLoginRedirect());
|
||||||
die;
|
die;
|
||||||
} else {
|
} else {
|
||||||
|
@ -84,7 +84,9 @@ class SessionController extends \PHPCI\Controller
|
||||||
*/
|
*/
|
||||||
public function logout()
|
public function logout()
|
||||||
{
|
{
|
||||||
$_SESSION = array();
|
unset($_SESSION['phpci_user']);
|
||||||
|
unset($_SESSION['phpci_user_id']);
|
||||||
|
|
||||||
session_destroy();
|
session_destroy();
|
||||||
header('Location: ' . PHPCI_URL);
|
header('Location: ' . PHPCI_URL);
|
||||||
die;
|
die;
|
||||||
|
@ -147,8 +149,8 @@ MSG;
|
||||||
$hash = password_hash($this->getParam('password'), PASSWORD_DEFAULT);
|
$hash = password_hash($this->getParam('password'), PASSWORD_DEFAULT);
|
||||||
$user->setHash($hash);
|
$user->setHash($hash);
|
||||||
|
|
||||||
$_SESSION['user'] = $this->userStore->save($user);
|
$_SESSION['phpci_user'] = $this->userStore->save($user);
|
||||||
$_SESSION['user_id'] = $user->getId();
|
$_SESSION['phpci_user_id'] = $user->getId();
|
||||||
|
|
||||||
header('Location: ' . PHPCI_URL);
|
header('Location: ' . PHPCI_URL);
|
||||||
die;
|
die;
|
||||||
|
@ -164,9 +166,9 @@ MSG;
|
||||||
{
|
{
|
||||||
$rtn = PHPCI_URL;
|
$rtn = PHPCI_URL;
|
||||||
|
|
||||||
if (!empty($_SESSION['login_redirect'])) {
|
if (!empty($_SESSION['phpci_login_redirect'])) {
|
||||||
$rtn .= $_SESSION['login_redirect'];
|
$rtn .= $_SESSION['phpci_login_redirect'];
|
||||||
$_SESSION['login_redirect'] = null;
|
$_SESSION['phpci_login_redirect'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $rtn;
|
return $rtn;
|
||||||
|
|
|
@ -56,7 +56,7 @@ class UserController extends Controller
|
||||||
|
|
||||||
public function profile()
|
public function profile()
|
||||||
{
|
{
|
||||||
$user = $_SESSION['user'];
|
$user = $_SESSION['phpci_user'];
|
||||||
$values = $user->getDataArray();
|
$values = $user->getDataArray();
|
||||||
|
|
||||||
if ($this->request->getMethod() == 'POST') {
|
if ($this->request->getMethod() == 'POST') {
|
||||||
|
@ -64,7 +64,7 @@ class UserController extends Controller
|
||||||
$email = $this->getParam('email', null);
|
$email = $this->getParam('email', null);
|
||||||
$password = $this->getParam('password', null);
|
$password = $this->getParam('password', null);
|
||||||
|
|
||||||
$_SESSION['user'] = $this->userService->updateUser($user, $name, $email, $password);
|
$_SESSION['phpci_user'] = $this->userService->updateUser($user, $name, $email, $password);
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = new Form();
|
$form = new Form();
|
||||||
|
@ -109,7 +109,7 @@ class UserController extends Controller
|
||||||
*/
|
*/
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
if (!$_SESSION['user']->getIsAdmin()) {
|
if (!$_SESSION['phpci_user']->getIsAdmin()) {
|
||||||
throw new ForbiddenException('You do not have permission to do that.');
|
throw new ForbiddenException('You do not have permission to do that.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ class UserController extends Controller
|
||||||
*/
|
*/
|
||||||
public function edit($userId)
|
public function edit($userId)
|
||||||
{
|
{
|
||||||
if (!$_SESSION['user']->getIsAdmin()) {
|
if (!$_SESSION['phpci_user']->getIsAdmin()) {
|
||||||
throw new ForbiddenException('You do not have permission to do that.');
|
throw new ForbiddenException('You do not have permission to do that.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ class UserController extends Controller
|
||||||
*/
|
*/
|
||||||
public function delete($userId)
|
public function delete($userId)
|
||||||
{
|
{
|
||||||
if (!$_SESSION['user']->getIsAdmin()) {
|
if (!$_SESSION['phpci_user']->getIsAdmin()) {
|
||||||
throw new ForbiddenException('You do not have permission to do that.');
|
throw new ForbiddenException('You do not have permission to do that.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ class User
|
||||||
{
|
{
|
||||||
public function __call($method, $params = array())
|
public function __call($method, $params = array())
|
||||||
{
|
{
|
||||||
$user = $_SESSION['user'];
|
$user = $_SESSION['phpci_user'];
|
||||||
|
|
||||||
if (!is_object($user)) {
|
if (!is_object($user)) {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue