Exemple #1
0
    def change_passwd(cls,uid, upass):
        _sql = 'update user set password = %s where id = %s'
        _args = (md5_str(upass), uid)
        print _args
        _sql_count, rt_list = SQL.excute_sql(_sql, _args)
        if _sql_count:
            return True, '修改成功'
        return False, '修改失败'

    # @classmethod
    # def user_reset(cls,id, username):
    #     _sql = 'update user set password = %s where id=%s and username=%s'
    #     newpassword = ''.join([choice(string.ascii_letters + string.digits) for i in range(8)])
    #     args = (md5_str(newpassword), id, username)
    #     _sql_count, rt_list = SQL.excute_sql(_sql, args)
    #     if _sql_count != 0:
    #         return True, '重置成功', newpassword
    #     return False, '重置失败', newpassword
    #
    # @classmethod
    # def validate_mpass(cls,params):
    #     mgrpass = params.get('mgrpass')
    #     mgruser = '******'
    #     ip = params.get('ip')
    #     cmd = params.get('cmd').split('\n')
    #     _sql = 'select * from user where username=%s and password=%s'
    #     _args = (mgruser,md5_str(mgrpass))
    #     _sql_count,rt_list = SQL.excute_sql(_sql,_args)
    #     if _sql_count != 0 :
    #         _ssh = Ssh_cmd(ip,cmd)
    #         return _ssh.ssh_cmd()
    #     return False,'管理员密码验证失败'
Exemple #2
0
 def change_passwd(cls, uid, upass):
     _sql = 'update user set password = %s where id = %s'
     _args = (md5_str(upass), uid)
     _sql_count, rt_list = SQL.excute_sql(_sql, _args)
     if _sql_count:
         return True, '修改成功'
     return False, '修改失败'
 def user_reset(cls,id, username):
     _sql = 'update user set password = %s where id=%s and username=%s'
     newpassword = ''.join([choice(string.ascii_letters + string.digits) for i in range(8)])
     args = (md5_str(newpassword), id, username)
     _sql_count, rt_list = SQL.excute_sql(_sql, args)
     if _sql_count != 0:
         return True, '重置成功', newpassword
     return False, '重置失败', newpassword
Exemple #4
0
 def validate_mpass(cls, params):
     mgrpass = params.get('mgrpass')
     mgruser = '******'
     ip = params.get('ip')
     cmd = params.get('cmd').split('\n')
     _sql = 'select * from user where username=%s and password=%s'
     _args = (mgruser, md5_str(mgrpass))
     _sql_count, rt_list = SQL.excute_sql(_sql, _args)
     if _sql_count != 0:
         _ssh = Ssh_cmd(ip, cmd)
         return _ssh.ssh_cmd()
     return False, '管理员密码验证失败'
Exemple #5
0
 def user_add(cls, params):
     username = params.get('username')
     password = params.get('password')
     age = params.get('age')
     telphone = params.get('telphone')
     email = params.get('email')
     _sql_select = 'select * from user where username = %s'
     _sql_insert = 'insert into user(username,password,age,telphone,email) values(%s,%s,%s,%s,%s)'
     agrs1 = (username, )
     _sql_count, rt_list = SQL.excute_sql(_sql_select, agrs1)
     if _sql_count != 0:
         return False, username + '已存在,请尝试其他的名字'
     args2 = (username, md5_str(password), age, telphone, email)
     SQL.excute_sql(_sql_insert, args2)
     return True, '添加成功'
Exemple #6
0
 def user_add(cls,params):
     username = params.get('username')
     password = params.get('password')
     cname = params.get('cname')
     telphone = params.get('telphone')
     email = params.get('email')
     permission = params.get('permission', '0')
     _sql_select = 'select * from user where username = %s'
     _sql_insert = 'insert into user(username,password,cname,telphone,email,permission) values(%s,%s,%s,%s,%s,%s)'
     agrs1 = (username,)
     _sql_count, rt_list = SQL.excute_sql(_sql_select, agrs1)
     if _sql_count != 0:
         return False, username + '已存在,请尝试其他的名字'
     args2 = (username, md5_str(password), cname, telphone, email, permission)
     SQL.excute_sql(_sql_insert, args2)
     return True, '添加成功'
Exemple #7
0
 def validate_login(cls,username, password):
     _columns  = ('id','username')
     _sql = 'select * from user where username = %s and password = %s'
     args = (username, md5_str(password))
     sql_count, rt_list = SQL.excute_sql(_sql, args)
     return dict(zip(_columns,rt_list[0])) if sql_count != 0 else None
Exemple #8
0
 def validate_login(cls, username, password):
     _columns = ('id', 'username')
     _sql = 'select * from user where username = %s and password = %s'
     args = (username, md5_str(password))
     sql_count, rt_list = SQL.excute_sql(_sql, args)
     return dict(zip(_columns, rt_list[0])) if sql_count != 0 else None