I'm writing a very simple mailing system for a Rails app. I'm using RESTful authentication. It's a fairly conventional setup, where I'm sending the same email when a user signs up and when a user forgets their password. I'm just having one problem that I can't seem to wrap my head around.
I'd like to use the same email template for both instances, even though the "new user" email will come from a users controller and the "forgot password" email will come from a passwords controller.
The email looks something like this:
<%=h @user.name %>,
Your membership details:
Username: <%=h @user.login %>
Password: <%=h @user.password %>
When a user signs up, this works just fine, causing an email that looks something like:
Bryan,
Your membership details:
Username: bryan
Password: password
Unfortunately, everything breaks when attempting to use this template to send a "forgot password" email from the passwords controller. The thing that's perplexing me, though, is that it only sort of breaks:
Bryan,
Your membership details:
Username: bryan
Password:
In other words, @user.name is still valid, as is @user.login. But for some reason in this state @user.password doesn't come through.
Thanks for the responses. To be clear, security really isn't an issue in this case, and for that reason it'd be nicer to be able to send a forgotten password in plain text rather than going through the resetting password process, but I do appreciate that this is usually not the case.