fix for issue #248

1.6
Harmj0y 2016-07-16 21:54:18 -04:00
parent 7d697cb4b7
commit ece3a3b540
1 changed files with 8 additions and 1 deletions

View File

@ -86,7 +86,14 @@ class Credentials:
Add a credential with the specified information to the database.
"""
cur = self.conn.cursor()
cur.execute("INSERT INTO credentials (credtype, domain, username, password, host, sid, notes) VALUES (?,?,?,?,?,?,?)", [credtype, domain, username, password, host, sid, notes] )
cur.execute("SELECT * FROM credentials WHERE LOWER(credtype) LIKE LOWER(?) AND LOWER(domain) LIKE LOWER(?) AND LOWER(username) LIKE LOWER(?) AND password LIKE ?", [credtype, domain, username, password])
results = cur.fetchall()
if results == []:
# only add the credential if the (credtype, domain, username, password) tuple doesn't already exist
cur.execute("INSERT INTO credentials (credtype, domain, username, password, host, sid, notes) VALUES (?,?,?,?,?,?,?)", [credtype, domain, username, password, host, sid, notes] )
cur.close()