adonisjs / ally

AdonisJS Social Authentication Provider
MIT License
159 stars 53 forks source link

Certain driver name can't be resolved when extending. #70

Closed AlexCatch closed 5 years ago

AlexCatch commented 5 years ago

I have multiple OAuth drivers for Github as I have two different consumers, one for a cli tool and one for a web app, each one has a different redirect URL.

When I register my GithubCLIDriver with the name githubCLI & attempt to resolve it through AllyManager.driver('githubCLI'); I get thrown a E_INVALID_PARAMETER: githubCLI is not a valid ally driver error.

If I swap that name to foo it resolves successfully.

It appears for some reason that the container is having a hard time resolving with the name githubCLI

Edit: It looks like the IOC has an issue with resolving names with any capital letters in it, I assume this isn't a Ally issue and more of an IOC issue so I'll close this.

Package version

2.1.3

Node.js and npm version

Node: 10.15.3 Npm: 6.4.1

Sample Code

Failing code

hooks.before.providersBooted(() => {
  const AllyManager = require('@adonisjs/ally/src/AllyManager');
  const Github = require('../app/SocialDrivers/GithubCLIDriver');

  AllyManager.extend('githubCLI', Github);
  console.log(AllyManager.driver('githubCLI')); // throws here
});

Working code

hooks.before.providersBooted(() => {
  const AllyManager = require("@adonisjs/ally/src/AllyManager");
  const Github = require('../app/SocialDrivers/GithubCLIDriver');

  AllyManager.extend('foo', Github);
  console.log(AllyManager.driver('foo')); //successfully prints driver
});