Skip to content

Commit

Permalink
Started work on merging login and register pages into one
Browse files Browse the repository at this point in the history
  • Loading branch information
PHLAK committed Jul 18, 2011
1 parent 2dfc674 commit 4eecbaa
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 81 deletions.
30 changes: 15 additions & 15 deletions application/layouts/layout.phtml
Expand Up @@ -27,14 +27,13 @@
<div id="siteTitle" class="floatLeft">
<?=$this->translate('issues');?>
</div>
<div id="accountInfo" class="floatRight">
<?php if(Zend_Registry::get('Default_DiContainer')->getAclService()->isAllowed('user', 'logout')): ?>
Signed in as <?= Zend_Auth::getInstance()->getIdentity()->getUsername(); ?> | <a href="<?=$this->url(array('controller'=>'auth','action'=>'logout'), null, true);?>"><?= $this->translate('sign_out'); ?></a>
<?php else: ?>
<a href="<?=$this->url(array('controller'=>'auth','action'=>'login'), null, true);?>"><?= $this->translate('sign_in'); ?></a> |
<a href="<?=$this->url(array('controller'=>'register','action'=>'index'), null, true);?>"><?=$this->translate('register');?></a>
<?php endif; ?>
</div>

<form method="post" action="#" id="siteSearchForm" class="floatRight">
<label id="siteSearch" for="siteSearchInput">
<input type="text" name="siteSearchInput" tabIndex="1" id="siteSearchInput" />
</label>
<button type="submit" id="siteSearchButton"><?=$this->translate('go');?></button>
</form>
</div>

<div class="clearfix">
Expand Down Expand Up @@ -69,14 +68,15 @@
<li <?php if(Zend_Controller_Front::getInstance()->getRequest()->getControllerName() == 'members'): ?>class="active"<?php endif; ?>>
<a href="#"><?=$this->translate('members');?></a>
</li>

<li class="floatRight">
<?php if(Zend_Registry::get('Default_DiContainer')->getAclService()->isAllowed('user', 'logout')): ?>
Signed in as <?= Zend_Auth::getInstance()->getIdentity()->getUsername(); ?> | <a href="<?=$this->url(array('controller'=>'auth','action'=>'logout'), null, true);?>"><?= $this->translate('sign_out'); ?></a>
<?php else: ?>
<a href="<?=$this->url(array('controller'=>'auth','action'=>'index'), null, true);?>"><?= $this->translate('sign_in'); ?> / <?=$this->translate('register');?></a>
<?php endif; ?>
</li>
</ul>

<form method="post" action="#" id="siteSearchForm" class="floatRight">
<label id="siteSearch" for="siteSearchInput">
<input type="text" name="siteSearchInput" tabIndex="1" id="siteSearchInput" />
</label>
<button type="submit" id="siteSearchButton"><?=$this->translate('go');?></button>
</form>
</div>
<?php $counts = Zend_Registry::get('Default_DiContainer')->getIssueService()->getIssueCounts(); ?>
<div class="tabListBottom">
Expand Down
55 changes: 44 additions & 11 deletions application/modules/default/controllers/AuthController.php
Expand Up @@ -6,40 +6,73 @@ public function init()
$this->_userService = Zend_Registry::get('Default_DiContainer')->getUserService();
$fm = $this->getHelper('FlashMessenger')->setNamespace('loginForm')->getMessages();
$this->view->loginForm = (count($fm) > 0) ? $fm[0] : $this->getLoginForm();
$this->view->registerForm = (count($fm) > 0) ? $fm[0] : $this->getRegisterForm();

$this->_aclService = Zend_Registry::get('Default_DiContainer')->getAclService();
}

public function loginAction()
public function indexAction()
{
if (!$this->_aclService->isAllowed('user', 'login')) {
return $this->_helper->redirector('index', 'index');
}
// Index...
}

public function logoutAction()
{
$this->_userService->logout();
return $this->_helper->redirector('index','index');
}

public function getLoginForm()
{
return $this->_userService->getLoginForm()->setAction($this->_helper->url->direct('authenticate-post'));
}

public function authenticateAction()
public function getRegisterForm()
{
return $this->_userService->getRegisterForm()->setAction($this->_helper->url->direct('register-post'));
}

public function authenticatePostAction()
{
// ACL Check for authentication action
if (!$this->_aclService->isAllowed('auth', 'login')) {
return $this->_helper->redirector('index', 'index');
}

$form = $this->view->loginForm;
$request = $this->getRequest();
if (!$request->isPost()) return $this->_helper->redirector('login');
if (!$request->isPost()) return $this->_helper->redirector('index');
$form->populate($request->getPost());
$vals = $form->getValues();
if (false === $this->_userService->authenticate($vals['username'], $vals['password'])) {
$form->setDescription($this->view->translate('login_failed'));
$this->_helper->FlashMessenger->setNamespace('loginForm')->addMessage($form);
$this->_helper->redirector('login');
$this->_helper->redirector('index');
}
return $this->_helper->redirector('index', 'index');
}

public function getLoginForm()
public function registerPostAction()
{
return $this->_userService->getLoginForm()->setAction($this->_helper->url->direct('authenticate'));
// ACL Check for registration action
if (!$this->_aclService->isAllowed('user', 'register')) {
return $this->_helper->redirector('index', 'index');
}

$form = $this->view->registerForm;
$request = $this->getRequest();
if (!$request->isPost()) return $this->_helper->redirector('index');
if (false === $form->isValid($request->getPost())) {
$form->setDescription($this->view->translate('registration_failed'));
$this->_helper->FlashMessenger->setNamespace('registerForm')->addMessage($form);
$this->_helper->redirector('index');
}
if (!$this->_userService->createFromForm($form)) {
$form->setDescription($this->view->translate('registration_failed'));
$this->_helper->FlashMessenger->setNamespace('registerForm')->addMessage($form);
return $this->_helper->redirector('index');
}
return $this->_helper->redirector('index', 'auth');
}

}
44 changes: 0 additions & 44 deletions application/modules/default/controllers/RegisterController.php

This file was deleted.

14 changes: 14 additions & 0 deletions application/modules/default/views/scripts/auth/index.phtml
@@ -0,0 +1,14 @@
<div class="floatLeft">
<div class="formWrapper">
<h2 class="formTitle"><?=$this->translate('sign_in');?></h2>
<?= $this->loginForm; ?>
</div>
</div>

<div class="floatRight">
<div class="formWrapper">
<h2 class="formTitle"><?=$this->translate('register');?></h2>
<?= $this->registerForm; ?>
</div>
</div>

4 changes: 0 additions & 4 deletions application/modules/default/views/scripts/auth/login.phtml

This file was deleted.

This file was deleted.

15 changes: 12 additions & 3 deletions public/css/style.css
Expand Up @@ -23,7 +23,7 @@ a:hover {
}

#pageWrap {
margin: 20px auto;
margin: 0 auto 20px;
width: 980px;
}

Expand All @@ -33,12 +33,22 @@ a:hover {
/* -------------------------------------------------------------------------- */

#siteHeader {
background: #0B5394 url(/images/sprites/gradients.png) repeat-x left -120px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
margin-bottom: 20px;
padding: 6px;
-moz-border-radius-bottomleft: 4px;
-moz-border-radius-bottomright: 4px;
-webkit-border-bottom-left-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
}

#siteTitle {
color: #FFF;
font-size: 1.5em;
font-weight: bold;
text-shadow: -1px -1px 0 #0B5394;
}

#accountInfo {
Expand All @@ -62,8 +72,7 @@ a:hover {
/* -------------------------------------------------------------------------- */

#siteSearchForm {
margin-top: 3px;
margin-right: 12px;
margin-top: 2px;
}

#siteSearch {
Expand Down

0 comments on commit 4eecbaa

Please sign in to comment.