How to Activate Users on HipChat Data Center Without Email Server
Purpose
To activate users who are created locally within HipChat Data Center that is running in the instance without an email server.
Solution
- Perform a backup of your database prior to running the steps below since it involves the process of modifying the database VERY IMPORTANT
Please run the following command on the node terminal:
PGPASSWORD=<postgres_password> psql -h <postgres_host> -U <postgres_user> -d <database_name> -c "SELECT * FROM users WHERE email = '<email_address>';"
Take note of the confirmed and metadata columns. This specific user should look something like this for example:
id | version | external_id | name | mention_name | email | password | title | photo_url | confirmed | created | is_deleted | is_enabled | is_guest | timezone | metadata | group_id ----+----------+-------------+-----------------+----------------------+-------------------------------+----------------------------------------------------------------------+---------------+-----------+-----------+----------------------------+------------+------------+----------+---------------+---------------------------------------+---------- 3 | J5ZV398B | | HipChat Example | HipChatExample | hipchat@example.com | {bcrypt}$2a$10$AUIhCoIb7AqFSXm0zAZLIOkFfABWny/nDdN4eyF3uWrUN2kwrSte. | | | 0 | 2018-05-24 03:18:03.329781 | 0 | 1 | 0 | UTC | {"activation_token":"zGXjijNczH"} | 1
- Take note of the user id
Update the confirmed column to 1:
PGPASSWORD=<postgres_password> psql -h <postgres_host> -U <postgres_user> -d <database_name> -c "UPDATE users SET confirmed=1 WHERE id = '<user_id>';"
Clear the metadata column:
PGPASSWORD=<postgres_password> psql -h <postgres_host> -U <postgres_user> -d <database_name> -c "UPDATE users SET metadata = NULL WHERE id = '<user_id>';"
Obtain root access
sudo dont-blame-hipchat
Set Postgres vars:
PGHOST=$(cat /hipchat/config/site.json | jq -r '.databases.hipchat_postgres.servers[0]' | cut -d: -f1) && PGUSER=$(cat /hipchat/config/site.json | jq -r '.databases.hipchat_postgres.user') && PGSCHEMA=$(cat /hipchat/config/site.json | jq -r '.databases.hipchat_postgres.schema') && export PG_CONNECT="psql -h $PGHOST -U $PGUSER -d $PGSCHEMA" && export PGPASSWORD=$(cat /hipchat/config/site.json | jq -r '.databases.hipchat_postgres.pass')
Set Redis vars:
RHOST=$($PG_CONNECT -t -c "SELECT value FROM configurations WHERE key='redishostname';") && RPORT=$($PG_CONNECT -t -c "SELECT value FROM configurations WHERE key='redisport';") && RPWD=$($PG_CONNECT -t -c "SELECT value FROM configurations WHERE key='redispass';") && export REDIS_CONNECT="redis-cli -h $RHOST -p $RPORT -a $RPWD"
Clear all sessions for this user, be sure to replace <user_id> with the user ID:
for key in `$REDIS_CONNECT KEYS '*' | grep -iE "session|^mobile:" | grep -w <user_id> | cut -d" " -f2`; do echo "Deleting $key"; $REDIS_CONNECT DEL $key; done
Last modified on Jun 29, 2018
Powered by Confluence and Scroll Viewport.