In PHP, I’ve always seen that using dedicated password functions such as “password_verify” is the best method. However, I’m currently working on a website where the original developer basically wrote a query that returns the userId by searching for the username and password hash. If there are results, then the user is logged in.
Can someone help explain to me why the latter is a bad idea? I understand about cryptographic functions being slow to prevent timing attacks. In the flip side, it almost seems to me that querying by username and password hash would be more secure as the query time would end the same as if the user wasn’t valid.