最佳实践:如何在 Zend Framework 中实现邀请系统?

发布于 2024-08-09 07:55:27 字数 432 浏览 2 评论 0原文

我已经构建了大部分功能,现在我陷入困境......

我正在创建一个私有的 Web 应用程序,该应用程序具有仅限邀请的注册系统。管理员用户向用户发送电子邮件邀请,用户单击链接,然后将他们带到一个页面,他们可以在其中创建已链接到其电子邮件地址的帐户。

当表单提交并且没有任何验证错误时,数据将首次插入数据库。邀请表的电子邮件列是唯一的,因此这是用户验证他们是否有权创建帐户所需的令牌。

我感到困惑的情况是当管理员用户尝试向同一电子邮件地址发送邀请时。电子邮件地址列是唯一的,因此存在 SQL 错误。我不知道在将该记录插入数据库之前是否应该检查该电子邮件地址,或者我应该做什么。

我想为丢失或意外删除的电子邮件创建重新发送邀请功能。这就是为什么我不希望管理员用户能够向同一个人发送重复的电子邮件,相反,他们应该使用重新发送功能。

我希望这一切都是有道理的。任何见解将不胜感激。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

无边思念无边月 2024-08-16 07:55:27

我用纸和笔来想象我真正想要的东西。如果流程清晰,我想你可以做到;)

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

等你爱我 2024-08-16 07:55:27

在尝试插入之前,我肯定会添加一个检查以查看该地址是否已在数据库中。您可以捕获异常,但我更愿意显式测试电子邮件地址是否存在。

给您一个想法...当电子邮件地址已经存在时,您可以让系统重新发送邀请。如果您这样做了,您也许可以通过不必编写额外的“重新发送邀请”功能来减少一些代码重复。只需在初始邀请请求上调用相同的“发送邀请”功能,或其他人描述的“重新发送邀请”链接即可。

我也喜欢其他人已经提到的“重新发送邀请”的想法,尤其是 philipnorton42 的实现。

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.

匿名的好友 2024-08-16 07:55:27

我会在您的表单中使用验证器,以便根据您已存储的电子邮件检查电子邮件地址。所以不应该有重复的条目。另外,我会实施一个操作,在一个漂亮的表格中列出您输入的所有帐户以及创建和激活时间。当然,操作和视图将支持分页,因此您可以轻松浏览数据。如果条目尚未激活,则应该有一个链接(也许还有一个图标),指向此特殊条目的重新发送电子邮件操作。将电子邮件重新发送到所有尚未激活的条目的另一个操作会很方便。最后但并非最不重要的一点是,我会实施报告行动,这样我就可以轻松地弄清楚发生了什么。

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.

扮仙女 2024-08-16 07:55:27

我想说瓦尔特是正确的,你也许需要画出你想要完成的事情。

但是,您似乎(据我所知)已准备好“重新发送邀请”按钮的所有信息,管理员可以单击该按钮来重新发送邀请。我会在后端创建一些报告,以便我查看已发送、已转换为用户以及尚未回复的邀请。在尚未答复的报告中添加一个重新发送个人邀请的按钮应该不会太难。

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.

一抹苦笑 2024-08-16 07:55:27

嗯,我会创建一个视图,其中所有“激活”都是可见的,并带有一个重新发送邀请的按钮?无需更改数据库内的记录。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文