I need to provide store's clients with a tool to check the status of their repair orders.
The clients don't have a user or password. They are only a record in the database. Yet I need to give them a way to log in to the webpage and check their status (ready or not). Forcing then to register is not an option.
I came up with this idea:
- The user is asked for their email address.
- The system checks if this email is registered in the database, generates a hash, and emails a special URL with the hash.
- The user checks the email and goes to this URL.
- When the system gets a request to the special address, it checks if the hash is in the database and retrieves the
user_id
. - If it's present, voila! "Hello John Doe. Your order #3454364 is ready for pickup"
The hash generation algorithm would be:
SELECT clients SET hash = SUBSTRING(PASSWORD(UUID()), 2);
The hash/password is salted and Bcrypt(ed) in the server. I could add a timeout where the hash is only valid for 1 day or something.
Is there something horribly wrong with this idea?
What work factor should I use for Bcrypt? It seems that the general idea is to increase the number until it takes ~1 second.
I like the output of MySQL's PASSWORD
for the hash generation because it's very URL friendly. But that's really the only reason. Any other suggestions?