channelUserService = $channelUserService; } /** * 登录 * * @param Request $request * @return mixed * @throws ApiException */ public function login(Request $request) { $all = $request->all(); $account = trim(getProp($all, 'account')); $password = trim(getProp($all, 'password')); if (strlen($account) < 1 || strlen($password) < 1) { Utils::throwError(ErrorConst::PARAM_ERROR_CODE); } // 登录 $user = $this->channelUserService->login($account, $password); return $this->success($user); } /** * 退出登录 * * @return mixed */ public function logout() { // 当前登录用户 $uid = Site::getUid(); // 退出 // $result = $this->channelUserService->logout($uid); $result = true; return $this->success(compact('result')); } /** * 修改密码 * * @param Request $request * @return mixed * @throws ApiException */ public function resetPassword(Request $request) { // 当前登录用户 $uid = Site::getUid(); $newPassword = trim($request->get('new_password', '')); if (strlen($newPassword) < 1) { Utils::throwError(ErrorConst::PARAM_ERROR_CODE); } // 退出 $result = $this->channelUserService->resetPassword($uid, $newPassword); return $this->success(compact('result')); } }