0
我在後端使用devise
和devise-token-auth
進行身份驗證,在客戶端使用'redux-auth`。設計不會通過登錄顯示正確的錯誤
我試圖讓設計發送正確的錯誤信息展現給客戶端的情況下,賬戶被暫時鎖定
這是我的user.rb
文件
# devise method to check if user is banned
def active_for_authentication?
super && !self.banned?
end
# message to send in case of ban. doesnt work yet
def inactive_message
self.banned? ? :locked : super
end
def banned?
return self.role == 'banned'
end
我devise.en.yml
文件
en:
devise:
confirmations:
confirmed: "Your email address has been successfully confirmed."
failure:
locked: "Your account is locked."
errors:
messages:
locked: "Your account has been banned"
我試圖用redux-auth或CURL登錄時似乎得到了設計的標準錯誤響應(我無法看到在devise.en.yml
文件的任何地方找到了給定的消息)
curl http://localhost:3000/auth/sign_in -d "[email protected]&password=123"
響應
{"success":false,"errors":["A confirmation email was sent to your account at '[email protected]'."]}
我在哪裏可以自定義消息?
謝謝,這個工作 – Kannaj