Remove auth. Choose user based on nginx HTTP basic auth
This commit is contained in:
parent
8fcd678dc8
commit
6c8ce9a78b
|
|
@ -36,6 +36,10 @@ EXPOSE 80
|
||||||
|
|
||||||
# Copy site into place.
|
# Copy site into place.
|
||||||
ADD . /var/www/cmc-sales
|
ADD . /var/www/cmc-sales
|
||||||
|
RUN mkdir /var/www/cmc-sales/app/tmp
|
||||||
|
RUN mkdir /var/www/cmc-sales/app/tmp/logs
|
||||||
|
RUN chmod -R 755 /var/www/cmc-sales/app/tmp
|
||||||
|
|
||||||
|
|
||||||
# Update the default apache site with the config we created.
|
# Update the default apache site with the config we created.
|
||||||
ADD conf/apache-vhost.conf /etc/apache2/sites-available/cmc-sales
|
ADD conf/apache-vhost.conf /etc/apache2/sites-available/cmc-sales
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED);
|
||||||
* In production mode, flash messages redirect after a time interval.
|
* In production mode, flash messages redirect after a time interval.
|
||||||
* In development mode, you need to click the flash message to continue.
|
* In development mode, you need to click the flash message to continue.
|
||||||
*/
|
*/
|
||||||
Configure::write('debug', 0);
|
Configure::write('debug', 1);
|
||||||
|
|
||||||
Configure::write('version', '1.0.1');
|
Configure::write('version', '1.0.1');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,25 @@
|
||||||
<?php
|
<?php
|
||||||
/* App Controller */
|
|
||||||
|
|
||||||
|
/* App Controller */
|
||||||
|
|
||||||
class AppController extends Controller {
|
class AppController extends Controller {
|
||||||
|
|
||||||
var $components = array('Auth', 'RequestHandler');
|
var $components = array('RequestHandler');
|
||||||
|
|
||||||
|
var $uses = array('User');
|
||||||
var $helpers = array('Javascript', 'Time', 'Html', 'Form');
|
var $helpers = array('Javascript', 'Time', 'Html', 'Form');
|
||||||
function beforeFilter() {
|
function beforeFilter() {
|
||||||
$this->set('currentuser', $this->Auth->user());
|
|
||||||
|
|
||||||
|
// Find the user that matches the HTTP basic auth user
|
||||||
|
$user = $this->User->find('first', array('recursive' => 0, 'conditions' => array('User.username'=>$_SERVER["PHP_AUTH_USER"])));
|
||||||
|
$this->set("currentuser", $user);
|
||||||
|
|
||||||
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
|
if($this->RequestHandler->isAjax()) {
|
||||||
$this->Auth->loginRedirect = array('controller' => 'enquiries', 'action' => 'index');
|
|
||||||
$this->Auth->allow('display');
|
|
||||||
$this->Auth->authorize = 'controller';
|
|
||||||
|
|
||||||
$this->Auth->autoRedirect = false;
|
|
||||||
|
|
||||||
if($this->RequestHandler->isAjax()) {
|
|
||||||
Configure::write('debug', 0);
|
Configure::write('debug', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//WTF. Why is this here??
|
|
||||||
function isAuthorized() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the current logged in user is an admin
|
* Check if the current logged in user is an admin
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ class UsersController extends AppController {
|
||||||
|
|
||||||
var $name = 'Users';
|
var $name = 'Users';
|
||||||
var $helpers = array('Html', 'Form', 'Javascript', 'Text');
|
var $helpers = array('Html', 'Form', 'Javascript', 'Text');
|
||||||
var $components = array('Acl', 'Auth', 'Cookie');
|
|
||||||
var $paginate = array(
|
var $paginate = array(
|
||||||
'limit' => 500,
|
'limit' => 500,
|
||||||
'Users' => array('order' => array('User.archived' => 'ASC', 'User.id' => 'asc'),
|
'Users' => array('order' => array('User.archived' => 'ASC', 'User.id' => 'asc'),
|
||||||
|
|
@ -12,50 +12,8 @@ class UsersController extends AppController {
|
||||||
'Enquiry' => array('order' => array('Enquiry.id' => 'desc'), 'limit' => 250),
|
'Enquiry' => array('order' => array('Enquiry.id' => 'desc'), 'limit' => 250),
|
||||||
);
|
);
|
||||||
|
|
||||||
function beforeFilter() {
|
|
||||||
$this->Auth->allow('add');
|
|
||||||
$this->set('currentuser', $this->Auth->user());
|
|
||||||
$this->Auth->autoRedirect = false;
|
|
||||||
//$this->login();
|
|
||||||
}
|
|
||||||
|
|
||||||
function login() { //Provided by the authComponent
|
|
||||||
$this->pageTitle = ': Login';
|
|
||||||
//$this->Session->setFlash(__('Please enter your Username and Password to continue', true));
|
|
||||||
|
|
||||||
|
|
||||||
/* Auth Cookie code from http://www.webdevelopment2.com/cakephp-auth-component-tutorial-3/ */
|
|
||||||
//– code inside this function will execute only when autoRedirect
|
|
||||||
//was set to false (i.e. in a beforeFilter).
|
|
||||||
if ($this->Auth->user()) {
|
|
||||||
if (!empty($this->data) && $this->data['User']['remember_me']) {
|
|
||||||
$cookie = array();
|
|
||||||
$cookie['username'] = $this->data['User']['username'];
|
|
||||||
$cookie['password'] = $this->data['User']['password'];
|
|
||||||
$this->Cookie->write('Auth.User', $cookie, true, '+2 weeks');
|
|
||||||
unset($this->data['User']['remember_me']);
|
|
||||||
}
|
|
||||||
$this->redirect($this->Auth->redirect());
|
|
||||||
}
|
|
||||||
if (empty($this->data)) {
|
|
||||||
$cookie = $this->Cookie->read('Auth.User');
|
|
||||||
if (!is_null($cookie)) {
|
|
||||||
if ($this->Auth->login($cookie)) {
|
|
||||||
// Clear auth message, just in case we use it.
|
|
||||||
// $this->Session->setFlash(__('Welcome back '.$cookie['username']), true);
|
|
||||||
$this->Session->del('Message.auth');
|
|
||||||
$this->redirect($this->Auth->redirect());
|
|
||||||
} else { // Delete invalid Cookie
|
|
||||||
$this->Cookie->del('Auth.User');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function logout() {
|
|
||||||
$this->Cookie->del('Auth.User');
|
|
||||||
$this->redirect($this->Auth->logout());
|
|
||||||
}
|
|
||||||
|
|
||||||
function index($type = 'user') {
|
function index($type = 'user') {
|
||||||
$this->User->recursive = 0;
|
$this->User->recursive = 0;
|
||||||
|
|
@ -90,13 +48,6 @@ class UsersController extends AppController {
|
||||||
|
|
||||||
$this->set('user', $user);
|
$this->set('user', $user);
|
||||||
|
|
||||||
/* $emailIDs = array();
|
|
||||||
foreach($user['Email'] as $email) {
|
|
||||||
$emailIDs[] = $email['id'];
|
|
||||||
}
|
|
||||||
$emails = $this->User->Email->find('all', array('conditions'=>array('Email.id'=>$emailIDs)));
|
|
||||||
$this->set('emails', $emails);
|
|
||||||
/ */
|
|
||||||
|
|
||||||
/** $this->render() is a better approach than I used in View Document. Keeps the views out of Elements and in the right directory.
|
/** $this->render() is a better approach than I used in View Document. Keeps the views out of Elements and in the right directory.
|
||||||
*
|
*
|
||||||
|
|
@ -121,7 +72,6 @@ class UsersController extends AppController {
|
||||||
case 'user':
|
case 'user':
|
||||||
$this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.user_id' => $id)));
|
$this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.user_id' => $id)));
|
||||||
$status_list = $this->User->Enquiry->Status->getJSON();
|
$status_list = $this->User->Enquiry->Status->getJSON();
|
||||||
|
|
||||||
$this->set('status_list', $status_list);
|
$this->set('status_list', $status_list);
|
||||||
$classNames = $this->User->Enquiry->Status->getClassNamesJSON();
|
$classNames = $this->User->Enquiry->Status->getClassNamesJSON();
|
||||||
$this->set('class_names', $classNames);
|
$this->set('class_names', $classNames);
|
||||||
|
|
@ -183,16 +133,6 @@ class UsersController extends AppController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if (!empty($this->data)) {
|
|
||||||
$this->User->create();
|
|
||||||
if ($this->User->save($this->data)) {
|
|
||||||
$this->Session->setFlash(__('The User has been saved', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
} else {
|
|
||||||
$this->Session->setFlash(__('The User could not be saved. Please, try again.', true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the default generated add() method. Used for system users, rather than contacts & principle contacts.
|
* the default generated add() method. Used for system users, rather than contacts & principle contacts.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue