diff --git a/application/api/controller/User.php b/application/api/controller/User.php index df4671315a77ab3c898055d841d5f8076573f08e..f9b0c88b0905a765008e6f3db2de656b22179981 100644 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -6,6 +6,7 @@ use app\common\controller\Api; use app\common\library\Ems; use app\common\library\Sms; use fast\Random; +use think\Config; use think\Validate; /** @@ -19,6 +20,11 @@ class User extends Api public function _initialize() { parent::_initialize(); + + if (!Config::get('fastadmin.usercenter')) { + $this->error(__('User center already closed')); + } + } /** @@ -38,7 +44,7 @@ class User extends Api */ public function login() { - $account = $this->request->post('account'); + $account = $this->request->post('account'); $password = $this->request->post('password'); if (!$account || !$password) { $this->error(__('Invalid parameters')); @@ -61,7 +67,7 @@ class User extends Api */ public function mobilelogin() { - $mobile = $this->request->post('mobile'); + $mobile = $this->request->post('mobile'); $captcha = $this->request->post('captcha'); if (!$mobile || !$captcha) { $this->error(__('Invalid parameters')); @@ -105,9 +111,9 @@ class User extends Api { $username = $this->request->post('username'); $password = $this->request->post('password'); - $email = $this->request->post('email'); - $mobile = $this->request->post('mobile'); - $code = $this->request->post('code'); + $email = $this->request->post('email'); + $mobile = $this->request->post('mobile'); + $code = $this->request->post('code'); if (!$username || !$password) { $this->error(__('Invalid parameters')); } @@ -150,11 +156,11 @@ class User extends Api */ public function profile() { - $user = $this->auth->getUser(); + $user = $this->auth->getUser(); $username = $this->request->post('username'); $nickname = $this->request->post('nickname'); - $bio = $this->request->post('bio'); - $avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars'); + $bio = $this->request->post('bio'); + $avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars'); if ($username) { $exists = \app\common\model\User::where('username', $username)->where('id', '<>', $this->auth->id)->find(); if ($exists) { @@ -169,7 +175,7 @@ class User extends Api } $user->nickname = $nickname; } - $user->bio = $bio; + $user->bio = $bio; $user->avatar = $avatar; $user->save(); $this->success(); @@ -184,8 +190,8 @@ class User extends Api */ public function changeemail() { - $user = $this->auth->getUser(); - $email = $this->request->post('email'); + $user = $this->auth->getUser(); + $email = $this->request->post('email'); $captcha = $this->request->post('captcha'); if (!$email || !$captcha) { $this->error(__('Invalid parameters')); @@ -200,10 +206,10 @@ class User extends Api if (!$result) { $this->error(__('Captcha is incorrect')); } - $verification = $user->verification; + $verification = $user->verification; $verification->email = 1; - $user->verification = $verification; - $user->email = $email; + $user->verification = $verification; + $user->email = $email; $user->save(); Ems::flush($email, 'changeemail'); @@ -219,8 +225,8 @@ class User extends Api */ public function changemobile() { - $user = $this->auth->getUser(); - $mobile = $this->request->post('mobile'); + $user = $this->auth->getUser(); + $mobile = $this->request->post('mobile'); $captcha = $this->request->post('captcha'); if (!$mobile || !$captcha) { $this->error(__('Invalid parameters')); @@ -235,10 +241,10 @@ class User extends Api if (!$result) { $this->error(__('Captcha is incorrect')); } - $verification = $user->verification; + $verification = $user->verification; $verification->mobile = 1; - $user->verification = $verification; - $user->mobile = $mobile; + $user->verification = $verification; + $user->mobile = $mobile; $user->save(); Sms::flush($mobile, 'changemobile'); @@ -254,10 +260,10 @@ class User extends Api */ public function third() { - $url = url('user/index'); + $url = url('user/index'); $platform = $this->request->post("platform"); - $code = $this->request->post("code"); - $config = get_addon_config('third'); + $code = $this->request->post("code"); + $config = get_addon_config('third'); if (!$config || !isset($config[$platform])) { $this->error(__('Invalid parameters')); } @@ -269,7 +275,7 @@ class User extends Api if ($loginret) { $data = [ 'userinfo' => $this->auth->getUserinfo(), - 'thirdinfo' => $result + 'thirdinfo' => $result, ]; $this->success(__('Logged in successful'), $data); } @@ -287,11 +293,11 @@ class User extends Api */ public function resetpwd() { - $type = $this->request->post("type"); - $mobile = $this->request->post("mobile"); - $email = $this->request->post("email"); + $type = $this->request->post("type"); + $mobile = $this->request->post("mobile"); + $email = $this->request->post("email"); $newpassword = $this->request->post("newpassword"); - $captcha = $this->request->post("captcha"); + $captcha = $this->request->post("captcha"); if (!$newpassword || !$captcha) { $this->error(__('Invalid parameters')); }