Skip to content

Commit

Permalink
refactor: Improve incorrect deprecation log message for auth adapter (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrezza authored Dec 6, 2022
1 parent 536bb2f commit b48c270
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions spec/AuthenticationAdapters.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,16 +590,17 @@ describe('AuthenticationProviders', function () {
);
});

it('can depreciate', async () => {
it('can deprecate', async () => {
await reconfigureServer();
const Deprecator = require('../lib/Deprecator/Deprecator');
const spy = spyOn(Deprecator, 'logRuntimeDeprecation').and.callFake(() => {});
const provider = getMockMyOauthProvider();
Parse.User._registerAuthenticationProvider(provider);
await Parse.User._logInWith('myoauth');
expect(spy).toHaveBeenCalledWith({
usage: 'auth.myoauth',
solution: 'auth.myoauth.enabled: true',
usage: 'Using the authentication adapter "myoauth" without explicitly enabling it',
solution:
'Enable the authentication adapter by setting the Parse Server option "auth.myoauth.enabled: true".',
});
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/Auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ const handleAuthDataValidation = async (authData, req, foundUser) => {
const authProvider = (req.config.auth || {})[provider] || {};
if (authProvider.enabled == null) {
Deprecator.logRuntimeDeprecation({
usage: `auth.${provider}`,
solution: `auth.${provider}.enabled: true`,
usage: `Using the authentication adapter "${provider}" without explicitly enabling it`,
solution: `Enable the authentication adapter by setting the Parse Server option "auth.${provider}.enabled: true".`,
});
}
if (!validator || authProvider.enabled === false) {
Expand Down

0 comments on commit b48c270

Please sign in to comment.