用户中心bug修复
This commit is contained in:
@@ -44,15 +44,12 @@ class User extends Admin{
|
|||||||
public function add(){
|
public function add(){
|
||||||
$model = \think\Loader::model('User');
|
$model = \think\Loader::model('User');
|
||||||
if(IS_POST){
|
if(IS_POST){
|
||||||
$username = input('post.username', '', 'trim');
|
$data = $this->request->param();
|
||||||
$email = input('post.email', '', 'trim');
|
|
||||||
$password = input('post.password', '', 'trim');
|
|
||||||
$repassword = input('post.repassword', '', 'trim');
|
|
||||||
//创建注册用户
|
//创建注册用户
|
||||||
$uid = $model->register($username, $password, $repassword, false);
|
$uid = $model->register($data['username'], $data['password'], $data['repassword'], $data['email'], false);
|
||||||
|
|
||||||
if(0 < $uid){
|
if(0 < $uid){
|
||||||
$userinfo = array('nickname' => $username, 'email' => $email, 'status' => 1,'reg_time'=>time(),'last_login_time'=>time(),'last_login_ip'=>get_client_ip(1));
|
$userinfo = array('nickname' => $data['username'], 'status' => 1,'reg_time'=>time(),'last_login_time'=>time(),'last_login_ip'=>get_client_ip(1));
|
||||||
/*保存信息*/
|
/*保存信息*/
|
||||||
if(!db('Member')->where(array('uid'=>$uid))->update($userinfo)){
|
if(!db('Member')->where(array('uid'=>$uid))->update($userinfo)){
|
||||||
return $this->error('用户添加失败!');
|
return $this->error('用户添加失败!');
|
||||||
@@ -60,7 +57,7 @@ class User extends Admin{
|
|||||||
return $this->success('用户添加成功!',url('index'));
|
return $this->success('用户添加成功!',url('index'));
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
return $this->error($this->showRegError($uid));
|
return $this->error($model->getError());
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$data = array(
|
$data = array(
|
||||||
@@ -85,18 +82,16 @@ class User extends Admin{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//为空
|
//为空
|
||||||
if(empty($data['password'])){
|
if($data['password'] == ''){
|
||||||
unset($data['password']);
|
unset($data['password']);
|
||||||
unset($data['salt']);
|
unset($data['salt']);
|
||||||
$model->save($data);
|
|
||||||
}else{
|
}else{
|
||||||
$data['salt'] = rand_string();
|
$data['salt'] = rand_string();
|
||||||
$data['password'] = md5($password.$data['salt']);
|
$data['password'] = md5($password.$data['salt']);
|
||||||
//不为空
|
|
||||||
$model->save($data,array('uid'=>$data['uid']));
|
|
||||||
}
|
}
|
||||||
|
$reuslt = $model->save($data,array('uid'=>$data['uid']));
|
||||||
|
|
||||||
if ($reuslt) {
|
if (false != $reuslt) {
|
||||||
return $this->success('修改成功!',url('index'));
|
return $this->success('修改成功!',url('index'));
|
||||||
}else{
|
}else{
|
||||||
return $this->error('修改失败!', '');
|
return $this->error('修改失败!', '');
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ class User extends Base{
|
|||||||
$data['username'] = $username;
|
$data['username'] = $username;
|
||||||
$data['salt'] = rand_string(6);
|
$data['salt'] = rand_string(6);
|
||||||
$data['password'] = $password;
|
$data['password'] = $password;
|
||||||
|
$data['repassword'] = $repassword;
|
||||||
$data['email'] = $email;
|
$data['email'] = $email;
|
||||||
$result = $this->validate(true)->save($data);
|
$result = $this->validate(true)->save($data);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
|
|||||||
Reference in New Issue
Block a user