【发布时间】:2019-01-06 00:43:43
【问题描述】:
我首先在一个域 app.example.com 中创建了 rails 应用程序,并在另一个域 www.example.com 中创建了静态站点。然后在 rails 应用程序中添加devise gem 并在静态站点中创建一个登录表单。这是登录表单的代码:
<form action="app.example.com/users/sign_in" method="post">
<input name="utf8" type="hidden" value="✓">
Email:<input type="text" name="email" value="admin@gmail.com">
Password:<input type="password" name="password" value="password">
<input name="authenticity_token", value="", type="hidden">
<button>Submit</button>
</form>
从静态站点登录后是否可以重定向到rails应用程序,因为它需要authentity_token并且很难在静态站点中生成authentity_token,并且可能存在csrf的问题。
【问题讨论】:
-
我认为更好的解决方案是在您的 Rails 应用程序中使用设计登录表单(无布局)的视图,并在您的静态站点中拥有该视图的 iframe。
-
在制作登录页面的 iframe 后如何重定向到
app.example.com? Rails 应用程序也显示在 iframe 中。
标签: ruby-on-rails devise csrf static-site