更新
This commit is contained in:
@@ -24,7 +24,7 @@ use app\adminapi\validate\LoginValidate;
|
||||
*/
|
||||
class LoginController extends BaseAdminController
|
||||
{
|
||||
public array $notNeedLogin = ['account', 'workWechatConfig', 'workWechatLogin', 'checkDbColumn'];
|
||||
public array $notNeedLogin = ['account', 'workWechatConfig', 'workWechatLogin', 'checkDbColumn', 'changeFirstPassword'];
|
||||
|
||||
/**
|
||||
* @notes 账号登录
|
||||
@@ -101,6 +101,41 @@ class LoginController extends BaseAdminController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 首次登录修改密码
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function changeFirstPassword()
|
||||
{
|
||||
$password = $this->request->post('password', '');
|
||||
$passwordConfirm = $this->request->post('password_confirm', '');
|
||||
|
||||
if (empty($password)) {
|
||||
return $this->fail('请输入新密码');
|
||||
}
|
||||
|
||||
if (strlen($password) < 6) {
|
||||
return $this->fail('密码长度不能少于6位');
|
||||
}
|
||||
|
||||
if ($password !== $passwordConfirm) {
|
||||
return $this->fail('两次输入的密码不一致');
|
||||
}
|
||||
|
||||
$token = $this->request->header('token');
|
||||
if (empty($token)) {
|
||||
return $this->fail('请先登录');
|
||||
}
|
||||
|
||||
$result = (new LoginLogic())->changeFirstPassword($token, $password);
|
||||
|
||||
if ($result === false) {
|
||||
return $this->fail(LoginLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('密码修改成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 退出登录
|
||||
* @return \think\response\Json
|
||||
|
||||
Reference in New Issue
Block a user