def post(self): form = LoginVerifyCodeForm(self.arguments) fail = False if form.validate() and self.validate_verify_code(form): user = User.get_or_none(mobile=self.get_argument("mobile")) if user: remember_me = self.get_argument("remember", "off") if remember_me == "on": expires_days = 30 else: expires_days = None self.login(user, expires_days) team = Team.get_or_none(owner_id=user.id) if team is None: self.redirect(self.reverse_url("club_create")) return if team.state == 0: self.redirect(self.reverse_url("club_wait_approve")) return if self.next_url: self.redirect(self.next_url) else: self.redirect(self.reverse_url("club_home")) return fail = True self.render("login-by-sms.html", form=form, fail=fail)
def post(self): form = LoginForm(self.arguments) if form.validate(): user = self.have_user(form.username.data) if user and User.check_password(user.password, form.password.data): remember_me = self.get_argument("remember", "off") if remember_me == "on": expires_days = 30 else: expires_days = None self.login(user, expires_days) team = Team.get_or_none(owner_id=user.id) if team is None: return self.redirect(self.reverse_url("club_create")) elif team.state == 0: return self.redirect(self.reverse_url("club_wait_approve")) elif self.next_url: return self.redirect(self.next_url) else: return self.redirect(self.reverse_url("club_home")) messages = [('danger', '登录失败:账号或密码不正确')] self.render("login.html", form=form, messages=messages)
def get(self): team = Team.get_or_none(owner_id=self.current_user.id) if team is None: return self.redirect(self.reverse_url("club_create")) elif team.state == 1: return self.redirect(self.reverse_url("club_home")) else: self.render("club/wait_approve.html")
def post(self, app_id): signature = self.get_argument("signature", None) msg_signature = self.get_argument("msg_signature", None) timestamp = self.get_argument("timestamp", None) nonce = self.get_argument("nonce", None) if not self.check_signature(signature, timestamp, nonce): raise tornado.web.HTTPError(403) self.logger.debug("receive_message: %s \n query: %s" % (self.request.body, self.request.query)) self.parse_message(self.request.body.decode(), msg_signature=msg_signature, timestamp=timestamp, nonce=nonce) message = self.get_message() if app_id == 'wx570bc396a51b8ff8': self.answer_test(message) return self.logger.debug("msg_type: %s form %s" % (message.type, app_id)) team = Team.get_or_none(wx_appid=app_id) if team is None: self.write("success") return if message.type == "subscribe": self.reply_subscribe(team, message) elif message.type == "text": self.reply_text(team, message) else: self.write("success")
def get_current_team(self): if not self.current_user: return None return Team.get_or_none(owner_id=self.current_user.id)