* Finish create user page.

This commit is contained in:
wangyuting
2023-06-20 13:34:22 +08:00
parent 3fcfa27e0d
commit d113078492
4 changed files with 75 additions and 60 deletions
+39
View File
@@ -7,3 +7,42 @@ window.switchAccount = function(account)
loadPage(link);
};
function computePasswordStrength(password)
{
if(password.length == 0) return 0;
var strength = 0;
var length = password.length;
var complexity = new Array();
for(i = 0; i < length; i++)
{
letter = password.charAt(i);
var asc = letter.charCodeAt();
if(asc >= 48 && asc <= 57)
{
complexity[0] = 1;
}
else if((asc >= 65 && asc <= 90))
{
complexity[1] = 2;
}
else if(asc >= 97 && asc <= 122)
{
complexity[2] = 4;
}
else
{
complexity[3] = 8;
}
}
var sumComplexity = 0;
for(i in complexity) sumComplexity += complexity[i];
if((sumComplexity == 7 || sumComplexity == 15) && password.length >= 6) strength = 1;
if(sumComplexity == 15 && password.length >= 10) strength = 2;
return strength;
}
+11 -38
View File
@@ -2,6 +2,7 @@ $(function()
{
password1Encrypted = false;
password2Encrypted = false;
verifyEncrypted = false;
passwordStrength = 0;
})
@@ -11,10 +12,14 @@ function changePassword(event)
{
password1Encrypted = false;
}
else
if($(event.target).attr('id') == 'password2')
{
password2Encrypted = false;
}
if($(event.target).attr('id') == 'verifyPassword')
{
verifyEncrypted = false;
}
}
function changeType(event)
@@ -86,44 +91,12 @@ function clickSubmit()
password1Encrypted = true;
password2Encrypted = true;
}
}
function computePasswordStrength(password)
{
if(password.length == 0) return 0;
var strength = 0;
var length = password.length;
var complexity = new Array();
for(i = 0; i < length; i++)
const password = $('input#verifyPassword').val().trim();
if(!verifyEncrypted && password)
{
letter = password.charAt(i);
var asc = letter.charCodeAt();
if(asc >= 48 && asc <= 57)
{
complexity[0] = 1;
}
else if((asc >= 65 && asc <= 90))
{
complexity[1] = 2;
}
else if(asc >= 97 && asc <= 122)
{
complexity[2] = 4;
}
else
{
complexity[3] = 8;
}
var rand = $('input#verifyRand').val();
$('input#verifyPassword').val(md5(md5(password) + rand));
verifyEncrypted = true;
}
var sumComplexity = 0;
for(i in complexity) sumComplexity += complexity[i];
if((sumComplexity == 7 || sumComplexity == 15) && password.length >= 6) strength = 1;
if(sumComplexity == 15 && password.length >= 10) strength = 2;
return strength;
}
+21 -21
View File
@@ -321,7 +321,7 @@ class userModel extends model
->setIF($this->post->password1 == false, 'password', '')
->setIF($this->post->email != false, 'email', trim($this->post->email))
->join('visions', ',')
->remove('new, group, password1, password2, verifyPassword, passwordStrength,passwordLength')
->remove('new, group, password1, password2, verifyPassword, passwordStrength,passwordLength, verifyRand')
->get();
$this->checkPassword();
@@ -362,30 +362,30 @@ class userModel extends model
->check('account', 'account')
->checkIF($this->post->email != '', 'email', 'email')
->exec();
if(!dao::isError())
if(dao::isError()) return false;
$userID = $this->dao->lastInsertID();
/* Set usergroup for account. */
if(isset($_POST['group']))
{
$userID = $this->dao->lastInsertID();
/* Set usergroup for account. */
if(isset($_POST['group']))
foreach($this->post->group as $groupID)
{
foreach($this->post->group as $groupID)
{
$data = new stdclass();
$data->account = $this->post->account;
$data->group = $groupID;
$data->project = '';
$this->dao->insert(TABLE_USERGROUP)->data($data)->exec();
}
$data = new stdclass();
$data->account = $this->post->account;
$data->group = $groupID;
$data->project = '';
$this->dao->insert(TABLE_USERGROUP)->data($data)->exec();
}
$this->computeUserView($user->account);
$this->loadModel('action')->create('user', $userID, 'Created');
$this->loadModel('mail');
if($this->config->mail->mta == 'sendcloud' and !empty($user->email)) $this->mail->syncSendCloud('sync', $user->email, $user->realname);
return $userID;
}
$this->computeUserView($user->account);
$this->loadModel('action')->create('user', $userID, 'Created');
$this->loadModel('mail');
if($this->config->mail->mta == 'sendcloud' and !empty($user->email)) $this->mail->syncSendCloud('sync', $user->email, $user->realname);
return $userID;
}
/**
+4 -1
View File
@@ -27,10 +27,11 @@ foreach($visionList as $key => $label)
formPanel
(
import('/js/md5.js', 'js'),
on::change('input[name=type]', 'changeType'),
on::change('#addCompany', 'changeAddCompany'),
on::change('input[name^=visions]', 'changeVision'),
on::change('#password1,#password2', 'changePassword'),
on::change('#password1,#password2,#verifyPassword', 'changePassword'),
on::click('button[type=submit]', 'clickSubmit'),
set::title($title),
formRow
@@ -71,6 +72,8 @@ formPanel
checkbox
(
set::id('addCompany'),
set::name('new[]'),
set::value('0'),
set::text($lang->company->create),
)
)