问题描述:

I have a management Rails app that manages the content on our main app. I'd like to be able to create accounts for people, populate information, and send them a forgot password url in a custom email to have them start using their account. I have everything but the forgot password url working. This is what I have so far:

My Action to create the forgot password token, and send the email

def send_staff_member_invite

staff_member = StaffMember.find(params[:id])

token, enc = Devise.token_generator.generate(staff_member.class, :reset_password_token)

staff_member.reset_password_token = enc

staff_member.reset_password_sent_at = Time.now.utc

if staff_member.save

StaffMemberMailer.send_staff_member_invite_email(staff_member, token).deliver

redirect_to staff_member_path

else

redirect_to send_invite_staff_member_path

end

end

Send email action

def send_staff_member_invite_email(staff_member, token)

@staff_member = staff_member

@company = Company.find(staff_member.company_id)

@token = token

mail(:to => @staff_member.email, :subject => "#{@company.name} Directory Invite")

end

The Email

<html>

<head>

<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />

</head>

<body>

<p>

Hi <%= @staff_member.first_name %>!<br/>

<a href="https://testapp/password/edit?reset_password_token=<%= @token %>">Click On This Link To Set Up Access To Edit Your Business Page.

</a><br/>

<br/>

Thank you

</p>

</body>

</html>

The problem is that I always get the error "Reset password token is invalid." I'm assuming it has to do with creating the token for one app on another possibly? Anyone know what could be causing it to always be invalid?

相关阅读:
Top