Reputation: 340
I'm missing something somewhere. I have the following Python3 code to insert a user and password
INSERT INTO table_name (emailAddress, password)
VALUES(%s, crypt(%s, gen_salt('bf')))
ON CONFLICT (emailAddress) DO NOTHING
RETURNING memberId;
This seems to be working fine. It inserts a nice hashed password in the DB but I looked Here(https://www.postgresql.org/docs/8.3/pgcrypto.html) and have the following code to retrieve it:
SELECT * from table_name
WHERE emailAddress='{email_addy}'
AND password=crypt('{password}', '{password}');
and obviously the query keeps coming back as nothing. Can someone point me in the direction how I can get the info I want? I'm guessing the hash isn't matching up?
Upvotes: 0
Views: 257
Reputation: 44285
You are giving the same argument to "crypt" twice.
You instead need to give it the cleartext password, and the hash column.
AND password=crypt('{password}', password);
Upvotes: 1