Skip to content

Commit ce6faeb

Browse files
committed
feat: allow disabling of auth
1 parent b10182f commit ce6faeb

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

spec/ParseUser.spec.js

+15
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,21 @@ describe('Parse.User testing', () => {
12091209
done();
12101210
});
12111211

1212+
it('can disable provider', async () => {
1213+
await reconfigureServer({
1214+
auth: {
1215+
facebook: {
1216+
enabled: false,
1217+
},
1218+
},
1219+
});
1220+
const provider = getMockFacebookProvider();
1221+
Parse.User._registerAuthenticationProvider(provider);
1222+
await expectAsync(Parse.User._logInWith('facebook')).toBeRejectedWith(
1223+
new Parse.Error(Parse.Error.UNSUPPORTED_SERVICE, 'This authentication method is unsupported.')
1224+
);
1225+
});
1226+
12121227
it('can not set authdata to null', async () => {
12131228
try {
12141229
const provider = getMockFacebookProvider();

src/RestWrite.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,8 @@ RestWrite.prototype.handleAuthDataValidation = function (authData) {
429429
return Promise.resolve();
430430
}
431431
const validateAuthData = this.config.authDataManager.getValidatorForProvider(provider);
432-
if (!validateAuthData) {
432+
const authProvider = (this.config.auth || {})[provider] || {};
433+
if (!validateAuthData || authProvider.enabled === false) {
433434
throw new Parse.Error(
434435
Parse.Error.UNSUPPORTED_SERVICE,
435436
'This authentication method is unsupported.'

0 commit comments

Comments
 (0)