intercom-rails
intercom-rails copied to clipboard
Viewing User models in ActiveAdmin makes Intercom Messenger act as if you are that user
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
- Create a User model with Devise
- Install ActiveAdmin and create an AdminUser model
- Create an admin module for editing User records
- View a User record in ActiveAdmin
- Congrats, Intercom now things you are the user you are viewing.
Logs
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.