如何在 Grails 中将密码发送到用户邮件?
我是 Grails 新手,我的应用程序有登录表单,但我尚未使用 spring-security-plugin。现在我想在登录表单中有一个名为“忘记密码”的链接,该链接将从数据库中检索密码,但我的问题是如何将其发送到该用户邮件 ID。
I am new to Grails, I have login form for my app for which I have not used spring-security-plugin. Now I want to have a link in login form called forgot password which will retrieve it from database, but my problem is how to send it to that user mail id.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
拜托,拜托,拜托 - 永远不要将用户的密码存储在数据库中。
如果您理解并接受永远不应该通过电子邮件向用户发送密码(甚至将其存储在数据库中),您将在下面找到一些有关从 grails 应用程序发送电子邮件的有用资源。
关于从 Grails 发送电子邮件,请阅读此页。
Please, please, please - never ever store your user's passwords in your database.
If you understand and accept that you should never email users their password (or even store it in the database) you will find some useful resources on sending emails from your grails application below.
On sending emails from Grails read this page.
您不应该向他们发送密码(这需要以未加密的方式存储它们,这是一个非常糟糕的主意),您应该为他们提供一个可以重置密码的工作流程。在注册时收集他们的电子邮件,然后向他们发送一个指向他们更改值的页面的链接。 Spring Security UI 插件对此提供支持 - 请参阅 < 中的“6 忘记密码”部分a href="http://burtbeckwith.github.com/grails-spring-security-ui/docs/manual/index.html" rel="nofollow">文档。
如果您不想使用整个 UI 插件,请随意在您的应用程序中使用该代码和工作流程。
Rather than sending them their password (which would require storing them unencrypted which is an incredibly bad idea) you should provide them a workflow where they can reset their password. Collect their email at signup, then send them a link to a page where they change the value. The Spring Security UI plugin has support for this - see section "6 Forgot Password" in the documentation.
If you don't want to use the whole UI plugin, feel free to just use that code and workflow in your application.