hubot-archive / hubot-auth

Assign roles to users and restrict command access in other scripts
149 stars 54 forks source link

2.0.0 (and 1.3.0) no longer support usernames with spaces #44

Closed mydevbox closed 8 years ago

mydevbox commented 8 years ago

I've recently attempted to upgrade from 1.2.0 to 2.0.0 and found that it no longer accepts usernames with spaces when assigning roles.

hubot: 2.19.0 adapter: HipChat nodejs: 4.5 hubot-auth: 2.0.0

When I attempt the following, I get no response.

hubot Joe User has developer role

I tracked the problem down to the @?([^\s]+) regex block which only grabs the first word. Version 1.2.0 used @?(.+) which does support spaces in usernames.

If the intent for this change was to force the use of @JoeUser instead of Joe User, the field that needs to be referenced for HipChat is 'mention_name', not 'name'.

"123456": { "id": "123456", "jid": "123456_123456@chat.hipchat.com", "name": "Joe User", "mention_name": "JoeUser", "email_address": "joe@gmail.com", "room": "123456_hughtest@conf.hipchat.com", "roles": [ "my" ] }

cecilia-sanare commented 8 years ago

Using .+ caused other issues where attempting to remove a role would also attempt to add the same role.

If you can submit a working PR with unit tests that include ids with space I'd be happy to take a look at it.

This is the PR that broke the use of spaces: https://github.com/hubot-scripts/hubot-auth/pull/24 This was the original PR that brought the regex issue to my attention: https://github.com/hubot-scripts/hubot-auth/pull/19