initial commit

This commit is contained in:
Chris Sewell
2012-11-28 03:55:08 -05:00
parent 7adb399b2e
commit cf140a2e97
3247 changed files with 492437 additions and 0 deletions

View File

@ -0,0 +1,83 @@
<?php
/**
* security actions.
*
* @package atlbiomed
* @subpackage security
* @author Your name here
* @version SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
*/
class securityActions extends sfActions
{
public function executeSecure()
{
}
/**
* Generates a random challenge string.
*
*/
private function generateChallenge()
{
return substr(preg_replace('/[\/\\\:*?"<>|.$^1]/', '', crypt(time())), 0, 16);
}
/**
* Executes index action
*
*/
public function executeIndex()
{
if($this->getRequest()->getMethod() == sfRequest::POST)
{
// check fields
$username = $this->getRequestParameter('username');
$password = $this->getRequestParameter('password');
/* $password = hash('sha256', $password);*/
// authenticate user
$c = new Criteria();
$c->add(UserPeer::USER_NAME, $username);
$c->add(UserPeer::PASSWORD, $password);
$user = UserPeer::doSelectOne($c);
if($user != null)
{
// success
$userId = $user->getId();
$this->getUser()->setAuthenticated(true);
$this->getUser()->addCredential($user->getUserType()->getTypeName());
$this->getUser()->setAttribute('name', $user->getDisplayName());
$this->getUser()->setAttribute('userId',$userId);
$this->redirect('scheduler');
}
}
$this->logoutUser();
}
public function executeLogout()
{
$this->logoutUser();
$this->redirect('security/index');
}
private function logoutUser()
{
$this->getUser()->setAuthenticated(false);
$this->getUser()->clearCredentials();
$this->getUser()->getAttributeHolder()->remove('name');
}
public function handleErrorIndex()
{
return sfView::SUCCESS;
}
}

View File

@ -0,0 +1,2 @@
all:
is_secure: off

View File

@ -0,0 +1,6 @@
indexSuccess:
javascripts: [%SF_PROTOTYPE_WEB_DIR%/js/prototype]
layout: noLayout
secureSuccess:
layout: noLayout

View File

@ -0,0 +1,32 @@
<?php use_helper('Validation') ?>
<?php echo form_tag('security/index'); ?>
<div class="loginForm">
<div class="loginFormInner">
<?php echo form_error('username') ?><br />
<?php echo form_error('password') ?><br />
<fieldset >
<legend>Please Log In</legend>
<div class="loginFormInnerRow">
<div>
<label for="username">Username:</label>
</div>
<div>
<?php echo input_tag('username'); ?>
</div>
</div>
<div class="loginFormInnerRow">
<div>
<label for="password">Password:</label>
</div>
<div>
<?php echo input_password_tag('password'); ?>
</div>
</div>
<div class="loginFormInnerRow">
<div></div>
<div><?php echo submit_tag('Login'); ?></div>
</div>
</fieldset>
</div>
</div>
</form>

View File

@ -0,0 +1,6 @@
<div class="secureModuleMain">
<div class="secureModuleMessage">
<?php echo image_tag('lock48'); ?>
<div>You are not authorized to view this page. Click <?php echo link_to('here', 'security/logout'); ?> to return to the application.</div>
</div>
</div>

View File

@ -0,0 +1,8 @@
fields:
username:
required:
msg: Please enter a username.
password:
required:
msg: Please enter a password.