完善用户中心功能
This commit is contained in:
@@ -20,8 +20,8 @@ class User extends Base {
|
||||
*/
|
||||
public function profile() {
|
||||
if ($this->request->isPost()) {
|
||||
$reuslt = (new Member())->editUser($this->request, session('userInfo.uid'));
|
||||
if (false !== $reuslt) {
|
||||
$result = (new Member())->editUser($this->request, session('userInfo.uid'));
|
||||
if (false !== $result) {
|
||||
return $this->success('修改成功!');
|
||||
} else {
|
||||
return $this->error('修改失败');
|
||||
@@ -41,7 +41,29 @@ class User extends Base {
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function repasswd() {
|
||||
return $this->fetch();
|
||||
if ($this->request->isAjax()) {
|
||||
$data = $this->request->post();
|
||||
|
||||
$user = Member::where('uid', $data['uid'])->findOrEmpty();
|
||||
if (!$user->isEmpty()) {
|
||||
if (md5($data['oldpassword'] . $user['salt']) !== $user['password']) {
|
||||
return $this->error('旧密码不正确!');
|
||||
}
|
||||
|
||||
$data['salt'] = \xin\helper\Str::random(6);
|
||||
$result = $user->save($data);
|
||||
|
||||
if (false !== $result) {
|
||||
return $this->success('修改成功!');
|
||||
} else {
|
||||
return $this->error('修改失败');
|
||||
}
|
||||
}else{
|
||||
return $this->error('无此用户!');
|
||||
}
|
||||
}else{
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user