Пример #1
0
 def get(self, *args, **kwargs):
     UserModify.uid = self.get_argument("uid")
     action = self.get_argument("action")
     if action == "modify":
         user_data = UserSqlOperation.user_modify(UserModify.uid)
         user_data_handled = UserDataManage.manage_user_list(user_data)
         self.render("users/user_modify.html", name=settings.template_variables, user_data=user_data_handled)
     elif action == "delete":
         UserSqlOperation.user_delete(UserModify.uid)
         js_str = "<script language='javascript'>window.location.href='/userlist';</script>"
         self.write(js_str)
Пример #2
0
 def post(self, *args, **kwargs):
     user_data = dict()
     user_data["user_name"] = self.get_argument("user_name")
     user_data["user_password"] = self.get_argument("user_password")
     result = Check.user_modify_check(user_data, True)
     if result == "ok":
         user_data["user_password"] = Check.md5(user_data["user_password"])
         UserSqlOperation.add_user(user_data)
         self.write("<script language='javascript'>alert('添加完成');window.location.href='/adduser';</script>")
     else:
         return self.write(result)
Пример #3
0
 def post(self, *args, **kwargs):
     data_dic = dict(user_name="", user_password="")
     for data in data_dic.keys():
         data_dic[data] = self.get_argument(data)
     result = Check.user_modify_check(data_dic, False)
     if result == "ok":
         data_dic["user_password"] = Check.md5(data_dic["user_password"])
         UserSqlOperation.user_modify_update(data_dic, UserModify.uid)
         self.write("<script language='javascript'>alert('修改完成');window.location.href='/userlist';</script>")
     elif result == "md5":
         UserSqlOperation.user_modify_update(data_dic, UserModify.uid)
         self.write("<script language='javascript'>alert('修改完成');window.location.href='/userlist';</script>")
     else:
         return self.write(result)
Пример #4
0
 def login_check(input_username, input_password):
     mysql_user_password = UserSqlOperation.check_user_login(input_username)
     if mysql_user_password:
         md5_input_password = Check.md5(input_password)
         if mysql_user_password[0][1] == md5_input_password:
             return "ok"
         else:
             return "Incorrect password"
     else:
         return "Invalid username"
Пример #5
0
 def login_check(input_username, input_password):
     mysql_user_password = UserSqlOperation.check_user_login(input_username)
     if mysql_user_password:
         md5_input_password = Check.md5(input_password)
         if mysql_user_password[0][1] == md5_input_password:
             return "ok"
         else:
             return "Incorrect password"
     else:
         return "Invalid username"
Пример #6
0
 def user_modify_check(result, flag):
     str_check_empty = "<script language='javascript'>alert('用户名或密码不能为空');window.history.back(-1);</script>"
     str_check_existed = "<script language='javascript'>alert('用户名已经存在');window.history.back(-1);</script>"
     str_check_length = "<script language='javascript'>alert('密码长度大于20位');window.history.back(-1);</script>"
     if result["user_name"] == "" or result["user_password"] == "":
         return str_check_empty
     elif len(result["user_password"]) == 32:
         return "md5"
     elif len(result["user_password"]) >= 20:
         return str_check_length
     elif len(result["user_password"]) < 20:
         if flag:
             check_username = UserSqlOperation.user_modify_check(result["user_name"])
             if check_username and check_username[0][0] == result["user_name"]:
                 return str_check_existed
             else:
                 return "ok"
         else:
             return "ok"
Пример #7
0
 def user_modify_check(result, flag):
     str_check_empty = "<script language='javascript'>alert('用户名或密码不能为空');window.history.back(-1);</script>"
     str_check_existed = "<script language='javascript'>alert('用户名已经存在');window.history.back(-1);</script>"
     str_check_length = "<script language='javascript'>alert('密码长度大于20位');window.history.back(-1);</script>"
     if result["user_name"] == "" or result["user_password"] == "":
         return str_check_empty
     elif len(result["user_password"]) == 32:
         return "md5"
     elif len(result["user_password"]) >= 20:
         return str_check_length
     elif len(result["user_password"]) < 20:
         if flag:
             check_username = UserSqlOperation.user_modify_check(
                 result["user_name"])
             if check_username and check_username[0][0] == result[
                     "user_name"]:
                 return str_check_existed
             else:
                 return "ok"
         else:
             return "ok"