UNPKG

react-native-gigya-sdk

Version:
60 lines (52 loc) 2.01 kB
import setSession from './setSession'; import getAccountInfo from './getAccountInfo'; import acceptConsentSchemas from './acceptConsentSchemas'; import finalizeRegistration from './finalizeRegistration'; import declineConsentSchemas from './declineConsentSchemas'; import resendVerificationEmail from './resendVerificationEmail'; import getUnacceptedConsentSchemas from './getUnacceptedConsentSchemas'; export default function (options) { return new Promise(async (resolve, reject) => { try { const unacceptedConsentSchemas = await getUnacceptedConsentSchemas(); if (unacceptedConsentSchemas !== null && unacceptedConsentSchemas !== void 0 && unacceptedConsentSchemas.acceptanceRequired) { await acceptConsentSchemas(unacceptedConsentSchemas.acceptanceRequired, { noUID: true }); } if (unacceptedConsentSchemas !== null && unacceptedConsentSchemas !== void 0 && unacceptedConsentSchemas.instantiationRequired) { await declineConsentSchemas(unacceptedConsentSchemas.instantiationRequired, { noUID: true }); } const account = await getAccountInfo({ noUID: true }); if (!account.isVerified) { await resendVerificationEmail({ noUID: true }); return reject({ actionRequired: { type: 'emailVerification' } }); } if (!account.isRegistered && !(options !== null && options !== void 0 && options.noFinalize)) { const response = await finalizeRegistration(options); if (!(options !== null && options !== void 0 && options.noSetSession)) { try { await setSession(response.sessionInfo.sessionToken, response.sessionInfo.sessionSecret); } catch (e) { console.log(e); } } return resolve(response); } resolve(account); } catch (e) { reject(e); } }); } //# sourceMappingURL=grantRequiredConsents.js.map