2017-06-14 43 views
0

我們使用Devise進行身份驗證。但是,我們使用更簡單的密碼恢復過程。我經歷了許多其他類似帖子,其問題是不同的。已完成401未經授權使用密碼申請表

這裏是我們的形式:

<%= form_tag send_new_password_users_path do %> 
    <%= text_field_tag 'username', nil %> 
    <%= button_tag "Request New Password" %> 
<% end %> 

我們得到以下錯誤信息:

Started POST "https://stackoverflow.com/users/send_new_password" for ::1 at 
    2017-06-14 10:40:09 -0400 
Processing by UsersController#send_new_password as HTML 
    Parameters: {"utf8"=>"✓", "authenticity_token"=>"qqV6bE4vY...", 
    "username"=>"Doe, John", "button"=>""} 
Completed 401 Unauthorized in 2ms (ActiveRecord: 0.4ms) 

感謝您的幫助。

回答

1

你期待用戶登錄之前,他可以做send_new_password哪(當然)是自我挫敗。

因此,您需要繞過該操作的用戶身份驗證。

class UserController < ApplicationController 
    before_action :authenticate_user!, except[:send_new_password] 
+0

有時候......我是個白癡。 – Jay

+0

我們都去過那裏。 :) – SteveTurczyn

相關問題