sdelements / lets-chat-ldap

LDAP plugin for Let's Chat
MIT License
33 stars 12 forks source link

LDAP authentication fails if username contains "-" #14

Closed madmas closed 9 years ago

madmas commented 9 years ago

Hi, we're experiencing a problem with username containing a "-", e.g. for composed names. From my expression, this is related tothe "-" as all other users are working fine.

here is what lets-chat log to the console:

{ [ValidationError: Validation failed]
  message: 'Validation failed',
  name: 'ValidationError',
  errors: 
   { username: 
      { [ValidatorError: Path `username` is invalid (karl-heinz).]
        message: 'Path `username` is invalid (karl-heinz).',
        name: 'ValidatorError',
        path: 'username',
        type: 'regexp',
        value: 'karl-heinz' } } }

Any suggestions what I can do about this?

hhaidar commented 9 years ago

This is actually an issue with the app itself.

I've pushed up a branch of let's chat that allows - in usernames: fix/username_dash

Please try that and I will merge it in master.

madmas commented 9 years ago

Hi, sorry for the long delay. I was able to give it a try this morning and got this error:

SyntaxError: Invalid regular expression: /^[^\.][a-z0-9_-\.]+[^\.]$/: Range out of order in character class
    at new RegExp (<anonymous>)
    at Object.<anonymous> (/home/admin/letschat/lets-chat/app/models/user.js:70:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/admin/letschat/lets-chat/migrootions/1421183479874-users.js:3:12)
    at Module._compile (module.js:456:26)

I changed the regex to

    match: /^[^\.][a-z0-9_\.-]+[^\.]$/i

and it works.

So we are able to login even with a - in the username :+1:

hhaidar commented 9 years ago

@madmas awesome, something like this has been merged into master