Skip to content

Commit

Permalink
feat: allow disabling of auth
Browse files Browse the repository at this point in the history
  • Loading branch information
dblythy committed May 16, 2022
1 parent b10182f commit ce6faeb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions spec/ParseUser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,21 @@ describe('Parse.User testing', () => {
done();
});

it('can disable provider', async () => {
await reconfigureServer({
auth: {
facebook: {
enabled: false,
},
},
});
const provider = getMockFacebookProvider();
Parse.User._registerAuthenticationProvider(provider);
await expectAsync(Parse.User._logInWith('facebook')).toBeRejectedWith(
new Parse.Error(Parse.Error.UNSUPPORTED_SERVICE, 'This authentication method is unsupported.')
);
});

it('can not set authdata to null', async () => {
try {
const provider = getMockFacebookProvider();
Expand Down
3 changes: 2 additions & 1 deletion src/RestWrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ RestWrite.prototype.handleAuthDataValidation = function (authData) {
return Promise.resolve();
}
const validateAuthData = this.config.authDataManager.getValidatorForProvider(provider);
if (!validateAuthData) {
const authProvider = (this.config.auth || {})[provider] || {};
if (!validateAuthData || authProvider.enabled === false) {
throw new Parse.Error(
Parse.Error.UNSUPPORTED_SERVICE,
'This authentication method is unsupported.'
Expand Down

0 comments on commit ce6faeb

Please sign in to comment.