Device token_authenticatable is not working with encrypted auth_tokens

荒凉一梦 提交于 2019-12-11 17:42:15

问题


We have recently encrypted all our auth_tokens in the users table. I have modified the authenticate_user_from_token! in ApplicationController to encrypt the params[:auth_token] before comparing in database. It fetches the user record and sign_in user, store: false creates an entry in sessions table.

def authenticate_user_from_token!
  user_token = encrypt(params[:auth_token].presence)
  user = user_token && User.find_by_authentication_token(user_token)
  if user
    sign_in user, store: false
  end
end

However, it doesn't actually log the user in. It takes me to the login page. Is Devise using the auth_token somewhere else where I need to encrypt it or am I missing something else?

来源:https://stackoverflow.com/questions/48998922/device-token-authenticatable-is-not-working-with-encrypted-auth-tokens

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!