账号问题新增
This commit is contained in:
@@ -7,6 +7,7 @@ use app\BaseController;
|
||||
use app\middleware\Auth;
|
||||
use app\service\CrawlerService;
|
||||
use app\service\UserConfigService;
|
||||
use app\service\UserService;
|
||||
use think\facade\Session;
|
||||
use think\facade\View;
|
||||
|
||||
@@ -87,6 +88,32 @@ class Crawler extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户修改密码
|
||||
*/
|
||||
public function changePassword()
|
||||
{
|
||||
try {
|
||||
$username = Session::get('username', '');
|
||||
if (empty($username)) {
|
||||
return json(['code' => 0, 'msg' => '未登录']);
|
||||
}
|
||||
|
||||
$old = $this->request->param('old_password', '');
|
||||
$new = $this->request->param('new_password', '');
|
||||
|
||||
if (empty($old) || empty($new)) {
|
||||
return json(['code' => 0, 'msg' => '旧密码和新密码不能为空']);
|
||||
}
|
||||
|
||||
$service = new UserService();
|
||||
$result = $service->changeUserPassword($username, $old, $new);
|
||||
return json($result);
|
||||
} catch (\Exception $e) {
|
||||
return json(['code' => 0, 'msg' => '修改失败: ' . $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存用户配置
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user