Last active
September 2, 2016 03:23
-
-
Save vvikramjhu/a922e6a7ff12974cc587d14d50bf02fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$imagePath = theme_path("images/login"); | |
?> | |
<style type="text/css"> | |
body { | |
background-color: #FFFFFF; | |
height: 700px; | |
} | |
img { | |
border: none; | |
} | |
#btnLogin { | |
padding: 0; | |
} | |
input:not([type="image"]) { | |
background-color: transparent; | |
border: none; | |
} | |
input:focus, select:focus, textarea:focus { | |
background-color: transparent; | |
border: none; | |
} | |
.textInputContainer { | |
font-family: Arial, Helvetica, sans-serif; | |
font-size: 11px; | |
color: #666666; | |
} | |
#divLogin { | |
background: transparent url(<?php echo "{$imagePath}/login.png"; ?>) no-repeat center top; | |
height: 520px; | |
width: 100%; | |
border-style: hidden; | |
margin: auto; | |
padding-left: 10px; | |
} | |
#divUsername { | |
padding-top: 153px; | |
padding-left: 50%; | |
} | |
#divPassword { | |
padding-top: 35px; | |
padding-left: 50%; | |
} | |
#txtUsername { | |
width: 240px; | |
border: 0px; | |
background-color: transparent; | |
} | |
#txtPassword { | |
width: 240px; | |
border: 0px; | |
background-color: transparent; | |
} | |
#txtUsername, #txtPassword { | |
font-family: Arial, Helvetica, sans-serif; | |
font-size: 11px; | |
color: #666666; | |
vertical-align: middle; | |
padding-top:0; | |
} | |
#divLoginHelpLink { | |
width: 270px; | |
background-color: transparent; | |
height: 20px; | |
margin-top: 12px; | |
margin-right: 0px; | |
margin-bottom: 0px; | |
margin-left: 50%; | |
} | |
#divLoginButton { | |
padding-top: 2px; | |
padding-left: 49.3%; | |
float: left; | |
width: 350px; | |
} | |
#btnLogin { | |
background: url(<?php echo "{$imagePath}/Login_button.png"; ?>) no-repeat; | |
cursor:pointer; | |
width: 94px; | |
height: 26px; | |
border: none; | |
color:#FFFFFF; | |
font-weight: bold; | |
font-size: 13px; | |
} | |
#divLink { | |
padding-left: 230px; | |
padding-top: 105px; | |
float: left; | |
} | |
#divLogo { | |
padding-left: 30%; | |
padding-top: 70px; | |
} | |
#spanMessage { | |
background: transparent url(<?php echo "{$imagePath}/mark.png"; ?>) no-repeat; | |
padding-left: 18px; | |
padding-top: 0px; | |
color: #DD7700; | |
font-weight: bold; | |
} | |
#logInPanelHeading{ | |
position:absolute; | |
padding-top:100px; | |
padding-left:49.5%; | |
font-family:sans-serif; | |
font-size: 15px; | |
color: #544B3C; | |
font-weight: bold; | |
} | |
.form-hint { | |
color: #878787; | |
padding: 4px 8px; | |
position: relative; | |
left:-254px; | |
} | |
</style> | |
<div id="divLogin"> | |
<div id="divLogo"> | |
<img src="<?php echo "{$imagePath}/logo.png"; ?>" /> | |
</div> | |
<form id="frmLogin" method="post" action="<?php echo url_for('auth/validateCredentials'); ?>"> | |
<input type="hidden" name="actionID"/> | |
<input type="hidden" name="hdnUserTimeZoneOffset" id="hdnUserTimeZoneOffset" value="0" /> | |
<?php | |
echo $form->renderHiddenFields(); // rendering csrf_token | |
?> | |
<div id="logInPanelHeading"><?php echo __('LOGIN Panel'); ?></div> | |
<div id="divUsername" class="textInputContainer"> | |
<?php echo $form['Username']->render(); ?> | |
<span class="form-hint" ><?php echo __('Username'); ?></span> | |
</div> | |
<div id="divPassword" class="textInputContainer"> | |
<?php echo $form['Password']->render(); ?> | |
<span class="form-hint" ><?php echo __('Password'); ?></span> | |
</div> | |
<div id="divLoginHelpLink"><?php | |
include_component('core', 'ohrmPluginPannel', array( | |
'location' => 'login-page-help-link', | |
)); | |
?></div> | |
<div id="divLoginButton"> | |
<input type="submit" name="Submit" class="button" id="btnLogin" value="<?php echo __('LOGIN'); ?>" /> | |
<?php if (!empty($message)) : ?> | |
<span id="spanMessage"><?php echo __($message); ?></span> | |
<?php endif; ?> | |
</div> | |
</form> | |
</div> | |
<div style="text-align: center"> | |
<?php include_component('core', 'ohrmPluginPannel', array( | |
'location' => 'other-login-mechanisms', | |
)); ?> | |
</div> | |
<?php include_partial('global/footer_copyright_social_links'); ?> | |
<script type="text/javascript"> | |
function calculateUserTimeZoneOffset() { | |
var myDate = new Date(); | |
var offset = (-1) * myDate.getTimezoneOffset() / 60; | |
return offset; | |
} | |
function addHint(inputObject, hintImageURL) { | |
if (inputObject.val() == '') { | |
inputObject.css('background', "url('" + hintImageURL + "') no-repeat 10px 3px"); | |
} | |
} | |
function removeHint() { | |
$('.form-hint').css('display', 'none'); | |
} | |
function showMessage(message) { | |
if ($('#spanMessage').size() == 0) { | |
$('<span id="spanMessage"></span>').insertAfter('#btnLogin'); | |
} | |
$('#spanMessage').html(message); | |
} | |
function validateLogin() { | |
var isEmptyPasswordAllowed = false; | |
if ($('#txtUsername').val() == '') { | |
showMessage('<?php echo __('Username cannot be empty'); ?>'); | |
return false; | |
} | |
if (!isEmptyPasswordAllowed) { | |
if ($('#txtPassword').val() == '') { | |
showMessage('<?php echo __('Password cannot be empty'); ?>'); | |
return false; | |
} | |
} | |
return true; | |
} | |
$(document).ready(function() { | |
/*Set a delay to compatible with chrome browser*/ | |
setTimeout(checkSavedUsernames,100); | |
$('#txtUsername').focus(function() { | |
removeHint(); | |
}); | |
$('#txtPassword').focus(function() { | |
removeHint(); | |
}); | |
$('.form-hint').click(function(){ | |
removeHint(); | |
$('#txtUsername').focus(); | |
}); | |
$('#hdnUserTimeZoneOffset').val(calculateUserTimeZoneOffset().toString()); | |
$('#frmLogin').submit(validateLogin); | |
}); | |
function checkSavedUsernames(){ | |
if ($('#txtUsername').val() != '') { | |
removeHint(); | |
} | |
} | |
if (window.top.location.href != location.href) { | |
window.top.location.href = location.href; | |
} | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class validateCredentialsAction extends sfAction { | |
protected $authenticationService; | |
protected $homePageService; | |
protected $beaconCommunicationService; | |
protected $loginService; | |
/** | |
* | |
* @return BeaconCommunicationsService | |
*/ | |
public function getBeaconCommunicationService() { | |
if(is_null($this->beaconCommunicationService)) { | |
$this->beaconCommunicationService = new BeaconCommunicationsService(); | |
} | |
return $this->beaconCommunicationService; | |
} | |
public function getLoginService() { | |
if(is_null($this->loginService)) { | |
$this->loginService = new LoginService(); | |
} | |
return $this->loginService; | |
} | |
public function execute($request) { | |
if ($request->isMethod(sfWebRequest::POST)) { | |
$loginForm = new LoginForm(); | |
$csrfToken = $request->getParameter('_csrf_token'); | |
if ($csrfToken != $loginForm->getCSRFToken()) { | |
$this->getUser()->setFlash('message', __('Csrf token validation failed'), true); | |
$this->forward('auth', 'retryLogin'); | |
} | |
$username = $request->getParameter('txtUsername'); | |
$password = $request->getParameter('txtPassword'); | |
$additionalData = array( | |
'timeZoneOffset' => $request->getParameter('hdnUserTimeZoneOffset', 0), | |
); | |
try { | |
$success = $this->getAuthenticationService()->setCredentials($username, $password, $additionalData); | |
if ($success) { | |
$this->getBeaconCommunicationService()->setBeaconActivation(); | |
$this->getLoginService()->addLogin(); | |
$this->redirect($this->getHomePageService()->getPathAfterLoggingIn($this->getContext())); | |
} else { | |
$this->getUser()->setFlash('message', __('Invalid credentials'), true); | |
$this->forward('auth', 'retryLogin'); | |
} | |
} catch (AuthenticationServiceException $e) { | |
$this->getUser()->setFlash('message', $e->getMessage(), false); | |
$this->forward('auth', 'login'); | |
} | |
} | |
return sfView::NONE; | |
} | |
/** | |
* | |
* @return AuthenticationService | |
*/ | |
public function getAuthenticationService() { | |
if (!isset($this->authenticationService)) { | |
$this->authenticationService = new AuthenticationService(); | |
} | |
return $this->authenticationService; | |
} | |
public function getHomePageService() { | |
if (!$this->homePageService instanceof HomePageService) { | |
$this->homePageService = new HomePageService($this->getUser()); | |
} | |
return $this->homePageService; | |
} | |
public function setHomePageService($homePageService) { | |
$this->homePageService = $homePageService; | |
} | |
public function getForm() { | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment