Esempio n. 1
0
def delete_infrequent_users():
    emails = request.get_json()
    emails_str = ','.join(('"' + e + '"') for e in emails)
    query = "SELECT * FROM user WHERE username  IN  (" + emails_str + ")"
    db = get_db()
    result = db.execute(query).fetchall()

    for r in result:
        UserData.remove_user(r['id'])
        dir_path = USER_PATH / str(r['id'])
        delete_folder(dir_path)
        delete_user_file(r['id'])

    UserData.send_delete_msg(emails)

    return "1"
Esempio n. 2
0
def delete_user_account():
    id = request.args.get('id')
    id = int(id)

    #Check admin or same user
    if g.user['is_admin'] or g.user['id'] == id:

        if g.user['is_admin'] and g.user['id'] != id:
            email = UserData.get_user(id)['username']
            UserData.send_delete_msg([email])

        UserData.remove_user(id)
        dir_path = USER_PATH / str(id)
        delete_folder(dir_path)

        delete_user_file(id)

        return '1'

    else:
        return abort('401')