request->getPost('ticket'); $validator = new WeChatOAValidator(); $openId = $validator->checkLoginOpenId($ticket); $connectRepo = new ConnectRepo(); $connect = $connectRepo->findByOpenId($openId, ConnectModel::PROVIDER_WECHAT_OA); $userRepo = new UserRepo(); $user = $userRepo->findById($connect->user_id); $validator = new AccountValidator(); $validator->checkIfAllowLogin($user); $this->handleLoginNotice($user); $auth = $this->getAppAuth(); $auth->saveAuthInfo($user); } public function bindLogin() { $post = $this->request->getPost(); $validator = new AccountValidator(); $user = $validator->checkUserLogin($post['account'], $post['password']); $validator = new WeChatOAValidator(); $openId = $validator->checkLoginOpenId($post['ticket']); $connect = new ConnectModel(); $connect->user_id = $user->id; $connect->open_id = $openId; $connect->provider = ConnectModel::PROVIDER_WECHAT_OA; $connect->create(); $this->handleLoginNotice($user); $auth = $this->getAppAuth(); $auth->saveAuthInfo($user); } public function bindRegister() { $post = $this->request->getPost(); $validator = new WeChatOAValidator(); $openId = $validator->checkLoginOpenId($post['ticket']); $registerService = new RegisterService(); $account = $registerService->handle(); $userRepo = new UserRepo(); $user = $userRepo->findById($account->id); $connect = new ConnectModel(); $connect->user_id = $user->id; $connect->open_id = $openId; $connect->provider = ConnectModel::PROVIDER_WECHAT_OA; $connect->create(); $this->handleLoginNotice($user); $auth = $this->getAppAuth(); $auth->saveAuthInfo($user); } protected function getAppAuth() { /** * @var $auth AuthService */ $auth = $this->getDI()->get('auth'); return $auth; } protected function handleLoginNotice(UserModel $user) { $notice = new AccountLoginNotice(); $notice->createTask($user); } }