diff --git a/module/common/view/customfield.html.php b/module/common/view/customfield.html.php
index 7c6e6f1e9a..adfed310c6 100644
--- a/module/common/view/customfield.html.php
+++ b/module/common/view/customfield.html.php
@@ -25,7 +25,7 @@
- save);?>
+
cancel, '', "btn close-dropdown");?>
restore, 'hiddenwin', "class='btn'");?>
diff --git a/module/user/control.php b/module/user/control.php
index 7a89603b1e..30645546ae 100644
--- a/module/user/control.php
+++ b/module/user/control.php
@@ -694,6 +694,7 @@ class user extends control
if($this->post->password) $password = $this->post->password;
if($this->get->password) $password = $this->get->password;
+ $account = trim($account);
if($this->user->checkLocked($account))
{
$failReason = sprintf($this->lang->user->loginLocked, $this->config->user->lockMinutes);
diff --git a/module/user/js/common.js b/module/user/js/common.js
index 35bfda6565..9571002df6 100644
--- a/module/user/js/common.js
+++ b/module/user/js/common.js
@@ -10,7 +10,7 @@ $(document).ready(function()
{
$('#verifyPassword').closest('form').find('#submit').click(function()
{
- var password = $('input#verifyPassword').val();
+ var password = $('input#verifyPassword').val().trim();
var rand = $('input#verifyRand').val();
$('input#verifyPassword').val(md5(md5(password) + rand));
});
diff --git a/module/user/js/login.js b/module/user/js/login.js
index abf7a8e173..241307566c 100644
--- a/module/user/js/login.js
+++ b/module/user/js/login.js
@@ -24,7 +24,7 @@ $(document).ready(function()
$('#loginPanel #submit').click(function()
{
- var password = $('input:password').val();
+ var password = $('input:password').val().trim();
var rand = $('input#verifyRand').val();
if(password.length != 32 && typeof(md5) == 'function') $('input:password').val(md5(md5(password) + rand));
});
diff --git a/module/user/model.php b/module/user/model.php
index 6c839d900b..61ff04c705 100644
--- a/module/user/model.php
+++ b/module/user/model.php
@@ -206,6 +206,7 @@ class userModel extends model
*/
public function create()
{
+ $_POST['account'] = trim($_POST['account']);
if(!$this->checkPassword()) return;
if(strtolower($_POST['account']) == 'guest') return false;
@@ -236,17 +237,18 @@ class userModel extends model
->check('account', 'account')
->checkIF($this->post->email != '', 'email', 'email')
->exec();
- if($this->post->group)
- {
- $data = new stdClass();
- $data->account = $this->post->account;
- $data->group = $this->post->group;
- $this->dao->insert(TABLE_USERGROUP)->data($data)->exec();
- }
-
if(!dao::isError())
{
- $this->loadModel('action')->create('user', $user->id, 'create');
+ $userID = $this->dao->lastInsertID();
+ if($this->post->group)
+ {
+ $data = new stdClass();
+ $data->account = $this->post->account;
+ $data->group = $this->post->group;
+ $this->dao->insert(TABLE_USERGROUP)->data($data)->exec();
+ }
+
+ $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);
}
@@ -268,6 +270,7 @@ class userModel extends model
$accounts = array();
for($i = 0; $i < $this->config->user->batchCreate; $i++)
{
+ $users->account[$i] = trim($users->account[$i]);
if($users->account[$i] != '')
{
if(strtolower($users->account[$i]) == 'guest') die(js::error(sprintf($this->lang->user->error->reserved, $i+1)));
@@ -289,7 +292,7 @@ class userModel extends model
$data[$i]->group = $users->group[$i] == 'ditto' ? (isset($prev['group']) ? $prev['group'] : '') : $users->group[$i];
$data[$i]->email = $users->email[$i];
$data[$i]->gender = $users->gender[$i];
- $data[$i]->password = md5($users->password[$i]);
+ $data[$i]->password = md5(trim($users->password[$i]));
$data[$i]->commiter = $users->commiter[$i];
$data[$i]->join = empty($users->join[$i]) ? '0000-00-00' : ($users->join[$i]);
$data[$i]->skype = $users->skype[$i];
@@ -356,6 +359,7 @@ class userModel extends model
*/
public function update($userID)
{
+ $_POST['account'] = trim($_POST['account']);
if(!$this->checkPassword(true)) return;
$oldUser = $this->getById($userID, 'id');
@@ -457,7 +461,7 @@ class userModel extends model
$accounts = array();
foreach($data->account as $id => $account)
{
- $users[$id]['account'] = $account;
+ $users[$id]['account'] = trim($account);
$users[$id]['realname'] = $data->realname[$id];
$users[$id]['commiter'] = $data->commiter[$id];
$users[$id]['email'] = $data->email[$id];
@@ -570,6 +574,7 @@ class userModel extends model
*/
public function resetPassword()
{
+ $_POST['account'] = trim($_POST['account']);
if(!$this->checkPassword()) return;
$user = $this->getById($this->post->account);
@@ -594,6 +599,8 @@ class userModel extends model
*/
public function checkPassword($canNoPassword = false)
{
+ $_POST['password1'] = trim($_POST['password1']);
+ $_POST['password2'] = trim($_POST['password2']);
if(!$canNoPassword and empty($_POST['password1'])) dao::$errors['password'][] = sprintf($this->lang->error->notempty, $this->lang->user->password);
if($this->post->password1 != false)
{