2017-03-17 49 views
0

我在後端使用devisedevise-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]'."]} 

我在哪裏可以自定義消息?

回答