mirror of
https://github.com/atlanticbiomedical/portal-legacy.git
synced 2025-07-02 01:47:28 -04:00
initial commit
This commit is contained in:
83
apps/atlbiomed/modules/security/actions/actions.class.php
Executable file
83
apps/atlbiomed/modules/security/actions/actions.class.php
Executable 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;
|
||||
}
|
||||
|
||||
}
|
2
apps/atlbiomed/modules/security/config/security.yml
Executable file
2
apps/atlbiomed/modules/security/config/security.yml
Executable file
@ -0,0 +1,2 @@
|
||||
all:
|
||||
is_secure: off
|
6
apps/atlbiomed/modules/security/config/view.yml
Executable file
6
apps/atlbiomed/modules/security/config/view.yml
Executable file
@ -0,0 +1,6 @@
|
||||
indexSuccess:
|
||||
javascripts: [%SF_PROTOTYPE_WEB_DIR%/js/prototype]
|
||||
layout: noLayout
|
||||
|
||||
secureSuccess:
|
||||
layout: noLayout
|
32
apps/atlbiomed/modules/security/templates/indexSuccess.php
Executable file
32
apps/atlbiomed/modules/security/templates/indexSuccess.php
Executable 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>
|
6
apps/atlbiomed/modules/security/templates/secureSuccess.php
Executable file
6
apps/atlbiomed/modules/security/templates/secureSuccess.php
Executable 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>
|
8
apps/atlbiomed/modules/security/validate/index.yml
Executable file
8
apps/atlbiomed/modules/security/validate/index.yml
Executable file
@ -0,0 +1,8 @@
|
||||
fields:
|
||||
username:
|
||||
required:
|
||||
msg: Please enter a username.
|
||||
|
||||
password:
|
||||
required:
|
||||
msg: Please enter a password.
|
Reference in New Issue
Block a user