Added Cookie login. Seems to work OK

This commit is contained in:
Karl Cordes 2010-01-10 16:34:31 -07:00
parent d7a76d9c53
commit 1d6aba8d90
5 changed files with 182 additions and 134 deletions

View file

@ -10,6 +10,13 @@ var $components = array('Auth', 'RequestHandler');
function beforeFilter() {
$this->set('currentuser', $this->Auth->user());
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Auth->loginRedirect = array('controller' => 'enquiries', 'action' => 'index');
$this->Auth->allow('display');
$this->Auth->authorize = 'controller';
/**
* Define the scheme for issue Types.
*/
@ -27,5 +34,10 @@ var $components = array('Auth', 'RequestHandler');
}
function isAuthorized() {
return true;
}
}
?>

View file

@ -3,7 +3,7 @@ class UsersController extends AppController {
var $name = 'Users';
var $helpers = array('Html', 'Form');
var $components = array('Acl','Auth');
var $components = array('Acl','Auth', 'Cookie');
var $paginate = array(
'Users' => array('order' => array('User.name' => 'asc'),
'limit' => 20
@ -19,6 +19,38 @@ class UsersController extends AppController {
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');
}
}
}
}

9
vendors/xtcpdf.php vendored
View file

@ -90,7 +90,7 @@ class XTCPDF extends TCPDF {
$fourthColWidth = -10;
$pageNo = $this->PageNoFormatted();
//$pageOf = $this->getAliasNbPages();
@ -98,13 +98,11 @@ class XTCPDF extends TCPDF {
$this->SetXY($boxXstart, 55);
$heightNeeded = $this->getNumLines($companyName, $secondColWidth);
//echo "Height needed: $heightNeeded";
$lineHeight = 6.40997; //Size of a single line of text. If the company name is more, multiply this by the number of lines it needs.
// $lineHeight = 0;
// $this->MultiCell($w, $h, $txt, $border, $align, $fill, $ln, $x, $y, $reseth, $stretch, $ishtml);
$this->MultiCell($firstColWidth, $lineHeight*$heightNeeded, "QUOTATION TO:", 'LTR', 'L', 0, 0);
@ -112,7 +110,7 @@ class XTCPDF extends TCPDF {
$this->MultiCell($thirdColWidth, $lineHeight*$heightNeeded, "FROM:", 'LT', 'L', 0, 0);
$this->MultiCell($fourthColWidth, $lineHeight*$heightNeeded, "<a href=\"mailto:$fromEmail\">$fromName</a>", 'TR', 'L', 0, 1, null,null, true,0,true); //Start a new line after this.
// echo "Last height: ".$this->getLastH();
$this->MultiCell($firstColWidth, 0, "EMAIL TO:", 'LR', 'L', 0, 0);
$this->MultiCell($secondColWidth, 0, "<a href=\"mailto:$emailTo\">$emailTo</a>", 'LR','L', 0, 0, null, null, true, 0, true);
@ -249,7 +247,6 @@ class XTCPDF extends TCPDF {
$pageNo = $this->PageNoFormatted();
$this->MultiCell(0, 0, "PAGE $pageNo OF {nb}", 0, "R", 0, 1);
$this->MultiCell(0, 0, "PRICING & SPECIFICATIONS", 0, "C", 0, 1);
$this->Ln();
$this->MultiCell($itemColwidth, 0, "ITEM\nNO.", 1, "C", 1, 0);

View file

@ -56,7 +56,7 @@ foreach ($quote['QuotePage'] as $quotePage):
<div class="related">
<div class="quoteproducts">
<h3><?php __('Products in this Quote');?></h3>
<?php if (!empty($quoteProducts)):?>
<table cellpadding = "0" cellspacing = "0" class="quoteproducts">

View file

@ -4,7 +4,7 @@
*
*
* Quotenik - Working CSS file based on the CakePHP default CSS.
* Modified by Karl Cordes 2008/2009
* Modified by Karl Cordes 2008/2009/2010
*
*
* PHP versions 4 and 5
@ -340,6 +340,13 @@ div.enquiriesindex {
}
div.quoteproducts {
clear: both;
display: block;
padding-top: 3%;
}
/* Tables */
table {
background: #fff;
@ -555,7 +562,7 @@ table.productoptions tr.defaultoption {
}
table.quoteproducts {
width: 70%;
width: 60%;
text-align: left;
}