此RoR和React-Native应用程序需要实现深层链接以进行密码恢复(以及其他操作)。如何在电子邮件中提供打开应用程序而不是浏览器的链接?
到目前为止,我很难确定所有需要发生的逻辑。我可以使用devise还是需要实现自定义控制器操作?
现在这是我的密码控制器
class Api::V1::PasswordController < Devise::PasswordsController
def create
respond_to do |format|
format.json do
self.resource =
resource_class.send_reset_password_instructions(resource_params)
puts('USER INFORMATION', resource_params)
yield resource if block_given?
if successfully_sent?(resource)
render :json => {:notice => "Please check your email for
further instruction."}.to_json, :status => 200
else
render :json => {:error => "The email you have entered is
incorrect."}.to_json, :status => 401
end
end
end
end
end
路线
post "reset_password" => "password#create"
设计视图
<p>Hello <%= @resource.email %>!</p>
<p>You have requested to change password. You can do this through the link below.</p>
<p><%= link_to 'Change my password now', edit_password_url(@resource, reset_password_token: @token) %></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
现在,edit_password_url会导致该Web应用程序包含一个编辑密码视图。我需要链接将用户重定向到移动应用中,以在其中编辑密码。