Skip to content

Commit 0483e9b

Browse files
hdcosmup
authored andcommitted
Fix unexpected error during signup for paid account
After subscription to a paid account and using PayPal, the SignupWizard would logout the user before showing the CongratulationPage which cause some backgorund actions to fail and raise exceptions (no user found, no user group key required for initialization of the db). This commit removes this unecessary logout and resolve a bunch of error related to this race condition. Co-authored-by: bedhub tutadb#1805
1 parent 3ea1d4f commit 0483e9b

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/common/subscription/UpgradeConfirmSubscriptionPage.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,7 @@ export class UpgradeConfirmSubscriptionPage implements WizardPageN<UpgradeSubscr
207207
}
208208

209209
private close(data: UpgradeSubscriptionData, dom: HTMLElement) {
210-
let promise = Promise.resolve()
211-
212-
if (data.newAccountData && locator.logins.isUserLoggedIn()) {
213-
promise = locator.logins.logout(false)
214-
}
215-
216-
promise.then(() => {
217-
emitWizardEvent(dom, WizardEventType.SHOW_NEXT_PAGE)
218-
})
210+
emitWizardEvent(dom, WizardEventType.SHOW_NEXT_PAGE)
219211
}
220212
}
221213

src/common/subscription/UpgradeSubscriptionWizard.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ export async function loadSignupWizard(
202202
const wizardPages = [
203203
wizardPageWrapper(UpgradeSubscriptionPage, new UpgradeSubscriptionPageAttrs(signupData)),
204204
wizardPageWrapper(SignupPage, new SignupPageAttrs(signupData)),
205-
wizardPageWrapper(InvoiceAndPaymentDataPage, invoiceAttrs),
206-
wizardPageWrapper(UpgradeConfirmSubscriptionPage, invoiceAttrs),
205+
wizardPageWrapper(InvoiceAndPaymentDataPage, invoiceAttrs), // this page will login the user after signing up with newaccount data
206+
wizardPageWrapper(UpgradeConfirmSubscriptionPage, invoiceAttrs), // this page will login the user if they are not login for iOS payment through AppStore
207207
wizardPageWrapper(UpgradeCongratulationsPage, new UpgradeCongratulationsPageAttrs(signupData)),
208208
]
209209

@@ -216,6 +216,8 @@ export async function loadSignupWizard(
216216
wizardPages,
217217
async () => {
218218
if (locator.logins.isUserLoggedIn()) {
219+
// this ensures that all created sessions during signup process are closed
220+
// either by clicking on `cancel`, closing the window, or confirm on the UpgradeCongratulationsPage
219221
await locator.logins.logout(false)
220222
}
221223

0 commit comments

Comments
 (0)