devise-token-auth

How to access current_user with devise-token_authenticatable gem?

孤街浪徒 提交于 2021-02-11 15:27:16
问题 I’m working on a small project that is using devise and devise-token_authenticatable in a Rails/GraphQL/Apollo/React setup. Project is setup using webpacker , so the front and back ends are both served from the same domain. Sign-in, register, log-out are all handle by the front end (React). I also need to point out this is not an API only app. It seems, server is not setting the current_user or the proper cookie and I’m getting a network error. Heroku logs shows the following error:

How to access current_user with devise-token_authenticatable gem?

可紊 提交于 2021-02-11 15:26:26
问题 I’m working on a small project that is using devise and devise-token_authenticatable in a Rails/GraphQL/Apollo/React setup. Project is setup using webpacker , so the front and back ends are both served from the same domain. Sign-in, register, log-out are all handle by the front end (React). I also need to point out this is not an API only app. It seems, server is not setting the current_user or the proper cookie and I’m getting a network error. Heroku logs shows the following error:

Devise_token_auth conflicts?

谁说胖子不能爱 提交于 2019-12-13 00:59:58
问题 Made a new API in rails 5 using default --api tag and installed devise_token_auth gem using command rails generate devise_token_auth:install User auth . On doing rake:db:migrate , I get this error undefined method 'devise' for User (call 'User.connection' to establish a connection) which is weird because devise_token_auth is built on top of devise.. So, commenting out routes throws error to user.rb file containing devise :database_authenticatable, :registerable, :recoverable, :rememberable,

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