rel 0.9
This commit is contained in:
@@ -75,6 +75,23 @@ def get_password(site, cipher):
|
||||
return username, decrypted_password
|
||||
return None, None
|
||||
|
||||
# Cancella una password dal database
|
||||
def delete_password(site):
|
||||
conn = sqlite3.connect(db_file)
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("DELETE FROM passwords WHERE site = ?", (site,))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
# Ottieni la lista di tutti i siti
|
||||
def list_sites():
|
||||
conn = sqlite3.connect(db_file)
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT site FROM passwords")
|
||||
sites = [row[0] for row in cursor.fetchall()]
|
||||
conn.close()
|
||||
return sites
|
||||
|
||||
# Endpoint per aggiungere una password
|
||||
@app.route('/add', methods=['POST'])
|
||||
def add_password_api():
|
||||
@@ -109,6 +126,29 @@ def get_password_api():
|
||||
|
||||
return jsonify({"site": site, "username": username, "password": password})
|
||||
|
||||
# Endpoint per cancellare una password
|
||||
@app.route('/delete', methods=['POST'])
|
||||
def delete_password_api():
|
||||
master_password = request.json.get('master_password')
|
||||
site = request.json.get('site')
|
||||
|
||||
if not authenticate(master_password):
|
||||
return jsonify({"error": "Master password errata"}), 403
|
||||
|
||||
delete_password(site)
|
||||
return jsonify({"message": "Password cancellata con successo"})
|
||||
|
||||
# Endpoint per listare tutti i siti
|
||||
@app.route('/list', methods=['POST'])
|
||||
def list_sites_api():
|
||||
master_password = request.json.get('master_password')
|
||||
|
||||
if not authenticate(master_password):
|
||||
return jsonify({"error": "Master password errata"}), 403
|
||||
|
||||
sites = list_sites()
|
||||
return jsonify({"sites": sites})
|
||||
|
||||
# Avvio dell'app
|
||||
if __name__ == '__main__':
|
||||
init_db()
|
||||
|
||||
Reference in New Issue
Block a user