views:

172

answers:

5

I've built out most of the functionality, now I'm getting stuck...

I am creating a private, 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.

When the form is submitted and does not have any validation errors, the data is inserted into the database for the first time. The email column of the invitations table is unique, so this is the token that the user needs in order to verify that they have permission to create an account.

The situation that I am confused about is when the admin user tries sending an invitation to the same email address. The email address column is unique so there is an SQL error. I don't know if I should do a check for that email address before inserting that record in the database, or what I should do.

I want to create a re-send invitation feature for emails that get lost, or accidentally deleted. Which is why I didn't want the admin user to be able to send a duplicate email to the same person, rather, they should use the re-send feature.

I hope this is all making sense. Any insights would be appreciated.

+1  A: 

I use paper and pen to visualaize what I realy want. If the flow is clear I think you can make it ;)

Valter
thanks. I forget to do that sometimes
Andrew
A: 

I would say that Valter is correct, you perhaps need to draw out what you want to accomplish.

However, you appear (from what I can tell) to have all of the information in place for a "Resend invitation" button that the admin can click on to resend the invitation. I would create some reports in the backend that would allow me to view invitations that have been sent, that converted into users and that haven't been answered yet. Adding a button to the haven't answered yet report that resends individual invitations shouldn't be too hard.

philipnorton42
A: 

Hum, i would create an view where all "Activations" are visible, with an button to just resend the invitation ? Without changing the record inside the database.

ArneRie
+1  A: 

I would definitely add a check to see if that address is already in the database before you attempt the insert. You could trap for the exception, but I would prefer to explicitly test for the presence of the email address.

An idea for you... When the email address already exists, you could make the system resend the invite. If you did that, you may be able to reduce some code repeat by not having to write an additional 'resend invite' function. Just call the same 'send invite' function on the initial invite request, or a 'resend invite' link described by others.

I also like the idea that others have already mentioned of the "Resend invite", especially philipnorton42's implementation.

borodimer
+1  A: 

I would use a validator inside your form, so the emailaddress is checked against your allready stored emails. So there should be no duplicate entry. Also i would implement an action that lists all your entered accounts and the creation- and activationtime in a nice table. Of course the action and view will support a pagination, so you can easy navigate through your data. If an entry has not yet been activated there should be a link, maybe an icon too, to a resend-the-email action for this special entry. And another action which resend the email to all not yet activated entries would be handy. Last but not least i would implement a reporting action so i can easily figure out whats going on.

DerKlops
I like your idea about the validator. That way I can update the form saying there is a duplicate entry in the database. But is a validator the best place to run a database query? Or should I create a function in my model that checks for duplicates and call that function from the validator?
Andrew
I would prefer the check-method inside your model. So the businesslogic stays where it has to be.
DerKlops