intercom-rails icon indicating copy to clipboard operation
intercom-rails copied to clipboard

Viewing User models in ActiveAdmin makes Intercom Messenger act as if you are that user

Open nickurban opened this issue 7 years ago • 1 comments

Version info

  • intercom-rails version: 0.3.8
  • Rails version: 5.1.5

Expected behavior

When viewing users as an AdminUser in ActiveAdmin, Intercom messenger should not be active.

Actual behavior

When viewing a User as an AdminUser in ActiveAdmin, Intercom messenger suddenly appears as if I were the User whose record I am viewing.

Steps to reproduce

  1. Create a User model with Devise
  2. Install ActiveAdmin and create an AdminUser model
  3. Create an admin module for editing User records
  4. View a User record in ActiveAdmin
  5. Congrats, Intercom now things you are the user you are viewing.

Logs

nickurban avatar Mar 26 '18 20:03 nickurban

Ah, it looks like intercom-rails picks up @user by default as the current user, which I suspect ActiveAdmin sets when editing a user.

Setting config.user.current = Proc.new { current_user } seems to have resolved the issue.

Given that lots of apps set @user when editing a user, I would suggest only pulling the current user from current_user (and perhaps @current_user) by default.

nickurban avatar Mar 26 '18 20:03 nickurban