UNPKG

react-native-gigya-sdk

Version:
53 lines (46 loc) 1.57 kB
import setSession from './setSession'; import getAccountInfo from './getAccountInfo'; import acceptConsentSchemas from './acceptConsentSchemas'; import finalizeRegistration from './finalizeRegistration'; 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) { await acceptConsentSchemas(unacceptedConsentSchemas, { 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