I’m not quite sure how to approach this issue:
I am creating a web application that has an invite only registration system. An admin user sends an email invitation to a user, the user clicks the link, and takes them to a page where they can create an account that has been linked to their email address.
My initial idea was to insert a row into my users table, with the verified column marked false. The problem is I have username, and password as required fields and username must be unique. So I can’t just insert an empty row to be filled out later.
Should I create a separate table for the invitations? What would be the best way to approach this type of scenario?
Update: The admin will enter the first name, last name, email address, and user role (permissions). So I will need to store all these things in the invitations table. I could also store date sent and update that value if the email ever needed to be re-sent.
Yes, you would make a separate table to manage invitations.
Then when an invitation is accepted, you have a few choices. First you’ll want to decide if you need to maintain an association to the original invitation either for tracking or “family tree” or some other historical purposes.
Next, if so, you’ll need to decide how you’ll do that. Delete the invitation and store any relevant info w/the user record? Keep the invitation record and set a foreign key?
I might be able to give some more fine-tuned advice if I know more about the system you intend to create.