完善用户中心功能

This commit is contained in:
2020-04-15 14:56:30 +08:00
parent 906dccda61
commit 10b40f0071
14 changed files with 370 additions and 16 deletions

View File

@@ -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();
}
}
/**