Beispiel #1
0
 def post(self, *args, **kwargs):
     data = self.json.loads(self.request.body)
     result = set_role(self, data)
     if result['status'] is True:
         return self.write(show(True, result['message'], "/passport/account"))
     else:
         return self.write(show(False, result['message'], ''))
Beispiel #2
0
 def post(self, *args, **kwargs):
     data = self.json.loads(self.request.body)
     form = signup.SignUpForm.from_json(data)
     if form.validate():
         result = sign_up(self, data)
         if result['status'] is False:
             return self.write(show(False, result['message'], ''))
         else:
             return self.write(show(True, result['message'], "/passport/account/login"))
     else:
         for key in form.errors:
             return self.write(show(False, str(form.errors[key]), ''))
Beispiel #3
0
 def post(self, *args, **kwargs):
     data = self.json.loads(self.request.body)
     form = RoleEditForm.from_json(data)
     if form.validate():
         result = edit_role(self, data)
         if result['status'] is True:
             return self.write(
                 show(True, result['message'], '/passport/roles'))
         else:
             return self.write(show(False, result['message'], ''))
     else:
         for key in form.errors:
             return self.write(show(False, str(form.errors[key]), ''))
 async def post(self, *args, **kwargs):
     data = self.json.loads(self.request.body)
     form = EditPermissionGroupForm.from_json(data)
     if form.validate():
         result = edit_group(self, data)
         if result['status'] is True:
             return self.write(
                 show(True, result['message'],
                      '/passport/permissions/group'))
         else:
             return self.write(show(False, result['message'], ''))
     else:
         for key in form.errors:
             return self.write(show(False, str(form.errors[key]), ''))
Beispiel #5
0
 def post(self, *args, **kwargs):
     """
     加入Form验证工具,科学的应对一亿只草泥马的问题。
     这里的form = login.LoginForm.from_json(data)是为了解决ajax提交过来的json数据而引入的,这个 from_json 在Form里初始化
     后续的注释将不写此段
     :param args:
     :param kwargs:
     :return:
     """
     data = self.json.loads(self.request.body)
     form = login.LoginForm.from_json(data)
     if form.validate():
         result = sign_in(self, data)
         if result['status'] is False:
             return self.write(show(False, result['message'], ''))
         else:
             return self.write(show(True, result['message'], self.get_argument('next', '/admin/index')))
     else:
         for key in form.errors:
             return self.write(show(False, str(form.errors[key]), ''))
Beispiel #6
0
 def post(self, user_id):
     result = set_admin(self, user_id)
     if result['status'] is True:
         return self.write(show(True, result['message'], "/passport/account"))
     else:
         return self.write(show(False, result['message'], ''))