Skip to content
Snippets Groups Projects
Commit d48fd37b authored by Uma's avatar Uma
Browse files

Password regex for validation has been centralized

parent 6f720c29
No related branches found
No related tags found
No related merge requests found
......@@ -17,4 +17,7 @@ $max_mailboxes = 3;
* This can be customized using runtime connector hook and avoid core file modifications.
* array('session' => 'Vtiger_CustomSession_Handler')
*/
$runtime_connectors = array();
\ No newline at end of file
$runtime_connectors = array();
//Password Regex for validation
$password_regex = '^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})';
\ No newline at end of file
......@@ -75,7 +75,9 @@ function vtws_changePassword($id, $oldPassword, $newPassword, $confirmPassword,
}
function isPasswordStrong($new_password){
if (preg_match('/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})/i', $new_password) == 1) {
$runtime_configs = Vtiger_Runtime_Configs::getInstance();
$password_regex = $runtime_configs->get('password_regex');
if (preg_match('/'.$password_regex.'/i', $new_password) == 1) {
return true;
}
return false;
......
......@@ -41,4 +41,19 @@
return $connector;
}
/**
* Function to fetch the value for given key
*/
public function get($key, $default = '') {
$value = '';
if(isset($GLOBALS[$key])) {
$value = $GLOBALS[$key];
}
if(empty($value) && !empty($default)) {
$value = $default;
}
return $value;
}
}
\ No newline at end of file
......@@ -28,6 +28,7 @@
<div class="row hide" id="errorMessage"></div>
<div class="row">
<div class="col-sm-6">
<input type='hidden' name='pwd_regex' value= {ZEND_json::encode($PWD_REGEX)} />
<table class="config-table input-table">
<thead>
<tr><th colspan="2">{vtranslate('LBL_DATABASE_INFORMATION', 'Install')}</th></tr>
......
......@@ -9,6 +9,7 @@
{strip}
<input type=hidden name="timeFormatOptions" data-value='{$DAY_STARTS}' />
<input type='hidden' name='pwd_regex' value= {ZEND_json::encode($PWD_REGEX)} />
{foreach key=BLOCK_LABEL_KEY item=FIELD_MODEL_LIST from=$RECORD_STRUCTURE}
{if $BLOCK_LABEL_KEY neq 'LBL_CALENDAR_SETTINGS'}
{assign var=BLOCK value=$BLOCK_LIST[$BLOCK_LABEL_KEY]}
......
......@@ -40,6 +40,7 @@
<input type="hidden" name="defaultCallDuration" value="{$USER_MODEL->get('callduration')}" />
<input type="hidden" name="defaultOtherEventDuration" value="{$USER_MODEL->get('othereventduration')}" />
<input type="hidden" name="isPreference" value="{$IS_PREFERENCE}" />
<input type='hidden' name='pwd_regex' value= {ZEND_json::encode($PWD_REGEX)} />
{if $IS_RELATION_OPERATION }
<input type="hidden" name="sourceModule" value="{$SOURCE_MODULE}" />
<input type="hidden" name="sourceRecord" value="{$SOURCE_RECORD}" />
......
......@@ -10,6 +10,7 @@
{strip}
<div class="listViewPageDiv" id="listViewContent">
<div class="col-sm-12 col-xs-12 full-height">
<input type='hidden' name='pwd_regex' value= {ZEND_json::encode($PWD_REGEX)} />
<div id="listview-actions" class="listview-actions-container">
<div class = "row">
<div class="btn-group col-md-2"></div>
......
......@@ -401,8 +401,12 @@ var vtUtils = {
* (?=.*[!@#\$%\^&\*]) The string must contain at least one special character, but we are escaping reserved RegEx characters to avoid conflict
* (?=.{8,}) The string must be eight characters or longer
*/
var strongPasswordRegex = new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})");
var isStrong = strongPasswordRegex.test(password)? true : false;
return isStrong;
var password_regex = jQuery('[name="pwd_regex"]').val();
if((typeof password_regex != 'undefined') && (password_regex != '')){
var strongPasswordRegex = new RegExp(password_regex);
var isStrong = strongPasswordRegex.test(password)? true : false;
return isStrong;
}
return false;
},
}
......@@ -111,6 +111,10 @@ class Install_Index_view extends Vtiger_View_Controller {
$viewer->assign('ADMIN_LASTNAME', $defaultParameters['admin_lastname']);
$viewer->assign('ADMIN_PASSWORD', $defaultParameters['admin_password']);
$viewer->assign('ADMIN_EMAIL', $defaultParameters['admin_email']);
$runtime_configs = Vtiger_Runtime_Configs::getInstance();
$password_regex = $runtime_configs->get('password_regex');
$viewer->assign('PWD_REGEX', $password_regex);
$viewer->view('Step4.tpl', $moduleName);
}
......
......@@ -167,6 +167,10 @@ class Users_List_View extends Settings_Vtiger_List_View {
$viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
$viewer->assign('SEARCH_VALUE', $searchValue);
$viewer->assign('SEARCH_DETAILS', $searchParams);
$runtime_configs = Vtiger_Runtime_Configs::getInstance();
$password_regex = $runtime_configs->get('password_regex');
$viewer->assign('PWD_REGEX', $password_regex);
}
/**
......
......@@ -172,6 +172,9 @@ class Users_PreferenceDetail_View extends Vtiger_Detail_View {
$viewer->assign("DAY_STARTS", Zend_Json::encode($dayStartPicklistValues));
$viewer->assign('IMAGE_DETAILS', $recordModel->getImageDetails());
$runtime_configs = Vtiger_Runtime_Configs::getInstance();
$password_regex = $runtime_configs->get('password_regex');
$viewer->assign('PWD_REGEX', $password_regex);
return parent::process($request);
}
......
......@@ -121,7 +121,7 @@ Class Users_PreferenceEdit_View extends Vtiger_Edit_View {
$fieldsInfo[$fieldName] = $fieldModel->getFieldInfo();
}
$viewer->assign('FIELDS_INFO', json_encode($fieldsInfo));
if($display) {
$this->preProcessDisplay($request);
}
......@@ -150,6 +150,10 @@ Class Users_PreferenceEdit_View extends Vtiger_Edit_View {
$viewer->assign("DAY_STARTS", Zend_Json::encode($dayStartPicklistValues));
$viewer->assign('TAG_CLOUD', $recordModel->getTagCloudStatus());
$viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
$runtime_configs = Vtiger_Runtime_Configs::getInstance();
$password_regex = $runtime_configs->get('password_regex');
$viewer->assign('PWD_REGEX', $password_regex);
parent::process($request);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment