Commit 5619d8c8 by 杨树贤

修改密码接口

parent b74e4ca4
......@@ -40,4 +40,22 @@ class AuthController extends Controller
return $this->setSuccessData(['uc_id' => $user['uc_id'], 'user' => $user]);
}
public function changePassword(Request $request)
{
$ucId = $request->input('uc_id');
$password = $request->input('password');
if (empty($ucId)) {
return $this->setError('uc_id不能为控');
}
if (empty($password)) {
return $this->setError('密码不能为空');
}
$result = UserService::changePassword($ucId, $password);
if (!$result) {
return $this->setError('修改密码失败,请确认uc_id');
}
return $this->setSuccess('修改密码成功');
}
}
......@@ -35,7 +35,7 @@ class UserController extends Controller
if (empty($mobile)) {
return $this->setError('mobile不能为空');
}
UserService::bindEmail($ucId, $mobile);
UserService::bindMobile($ucId, $mobile);
return $this->setSuccess('绑定成功');
}
......
......@@ -4,6 +4,7 @@ namespace App\Http\Services;
use App\Exceptions\InvalidRequestException;
use App\Http\Models\UserModel;
use http\Client\Curl\User;
class UserService
{
......@@ -99,4 +100,14 @@ class UserService
'update_time' => time(),
]);
}
//修改密码
public static function changePassword($ucId, $password)
{
return UserModel::where('uc_id', $ucId)->update([
'password' => $password,
'update_time' => time(),
]);
}
}
......@@ -6,6 +6,8 @@ use Illuminate\Support\Facades\Route;
Route::namespace('Api')->group(function () {
Route::match(["GET", "POST"], '/auth/register', 'AuthController@register');
Route::match(["GET", "POST"], '/auth/login', 'AuthController@login');
Route::match(["GET", "POST"], '/auth/changePassword', 'AuthController@changePassword');
Route::match(["GET", "POST"], '/user/bindEmail', 'UserController@bindEmail');
Route::match(["GET", "POST"], '/user/bindMobile', 'UserController@bindMobile');
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment