def post(self, *args, **kwargs): username = self.get_argument('username', '') password = self.get_argument('password', '') #用户和名密码不可为空 if (not username) or (not password): self.write("<script>alert('用户名或者密码不能为空');history.back();</script>") else: try: t_user = User.get(username=username) if get_password(password) == t_user.password: self.set_secure_cookie('uid', str(t_user.id)) self.redirect(self.get_argument('next', '/')) else: self.write( "<script>alert('用户名或密码错误');history.back();</script>") except DoesNotExist: self.write( "<script>alert('您输入的用户名不存在');history.back();</script>")
def post(self): if is_reg: username = self.get_argument('username') email = self.get_argument('email') password = self.get_argument('password') re_password = self.get_argument('re_password') if re_password == password: #简单加密 password = get_password(password) User.create(username=username, email=email, password=password, reg_data=datetime.now()) self.redirect(self.get_login_url()) else: self.write( "<script>alert('两次输入的密码不一致');history.back();</script>") else: self.write("<script>alert('注册功能暂时不对外开放');history.back();</script>")