vesse / node-ldapauth-fork

Simple node.js module to authenticate against an LDAP server
Other
127 stars 79 forks source link

VerifyCredentials and LdapAuth #78

Closed tactusoft closed 4 years ago

tactusoft commented 5 years ago

Hi, From Colombia thanks for this libs. But I have a Question. I am using UserService of loopback/security. This asynchronous library called verifyCredentials and returns a promise. How do I make auth.authenticate wait to return the promise? Thank you very much.

async verifyCredentials(credentials: Credentials): Promise<Usuario> {
auth.authenticate(username + '@upra.local', credentials.contrasenia, (err, user) => {
        console.error('LdapAuth: ', err);
        if (!err) {
          console.error('LdapAuth: ', user);
          return new Usuario();
        } else {
          throw new HttpErrors.Unauthorized(invalidCredentialsError);
        }
      });

        return new Usuario();
}
vesse commented 4 years ago

Maybe like this