So, I found gems like pretender, user_impersonate2 and switch_user. They all seem to accomplish the similar goal - switching current_user
for systems like Devise, for "monolith" Rails apps.
I have a React client talking to a Rails app. The admin page is implemented directly in Rails (it's a view), and the client is separated. Currently, client makes POST requests to Devise routes that provide an access_token
via devise-jwt
, and saves the token in browser's localstorage
.
Is there a recommended way on allowing administrators to log in as users and be redirected from the admin (Rails) page to the client (React) page? Preferably with minimum changes to the frontend code, but I can make do with that.
I thought about sharing cookies via a shared root domain, but that smells of security issues to me.
I'm not sure how can I make the client app to "listen" for the token change made in the Rails app, or any similar way of changing the current user from the client's perspective.