Ejemplo n.º 1
0
def changeName(fileName):
    if (len(fileName) <= 35):
        # print "idCard is 15"
        idCard = fileName[-15:len(fileName)]
        # print idCard
        # temp_idCard = temp_name[-15:len(temp_name)]
        serviceTime = fileName[0:8] + '_' + fileName[8:14]
        return md5_util.get_md5_value(idCard) + '_' + serviceTime + '_' + str(
            uuid.uuid1()) + '.jpg'
    else:
        # print "idCard is 18"
        idCard = fileName[-18:len(fileName)]
        # print idCard
        # temp_idCard = temp_name[-18:len(temp_name)]
        serviceTime = fileName[0:8] + '_' + fileName[8:14]
        return md5_util.get_md5_value(idCard) + '_' + serviceTime + '_' + str(
            uuid.uuid1()) + '.jpg'
Ejemplo n.º 2
0
 def login(email, password):
     password = get_md5_value(password)
     user = DBHelper.get_user(email)
     if user:
         if user.password == password:
             session['email'] = email
             return True
         else:
             return False
     return False
Ejemplo n.º 3
0
 def update_password(id, password):
     password = get_md5_value(password)
     cursor = DBHelper.mysql.get_db().cursor()
     sql = 'update user set password=%s where id=%s'
     cursor.execute(sql, (password, id))
     DBHelper.mysql.get_db().commit()
Ejemplo n.º 4
0
 def create_user(username, email, password):
     password = get_md5_value(password)
     cursor = DBHelper.mysql.get_db().cursor()
     sql = 'insert into user (username, email, password) values (%s, %s, %s)'
     cursor.execute(sql, (username, email, password))
     DBHelper.mysql.get_db().commit()
Ejemplo n.º 5
0
 def generate_url(user):
     key = random.sample('zyxwvutsrqponmlkjihgfedcba', 6)
     time = datetime.datetime.now()
     md5 = get_md5_value(user.username + key + time)
     DBHelper.create_reset_info(user.id, time, md5)
     return '127.0.0.1/' + md5