Skip to content

Commit

Permalink
web/satellite/vuetify-poc: fix flaky signup
Browse files Browse the repository at this point in the history
redirect

This change fixes an issue where the v2 signup will eroneously redirect
to the v1 signup because satellite config might have not been fetched
at that point.

Issue: #6676

Change-Id: I22f521fb67e3fa75748bc44d48d81fbdafd1de62
  • Loading branch information
wilfred-asomanii authored and Storj Robot committed Jan 11, 2024
1 parent cbe9c01 commit f502f50
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions web/satellite/vuetify-poc/src/views/Signup.vue
Expand Up @@ -183,7 +183,7 @@
</v-card>

<VueHcaptcha
v-if="captchaConfig.hcaptcha.enabled"
v-if="captchaConfig?.hcaptcha.enabled"
ref="hcaptcha"
:sitekey="captchaConfig.hcaptcha.siteKey"
:re-captcha-compat="false"
Expand Down Expand Up @@ -352,7 +352,7 @@ const passMinLength = computed((): number => {
*/
const satellite = computed({
get: () => {
const satName = configStore.state.config.satelliteName;
const satName = configStore.state.config.satelliteName ?? '';
const item = satellitesHints.find(item => item.satellite === satName);
return item ?? { satellite: satName, hint: '' };
},
Expand Down Expand Up @@ -401,8 +401,8 @@ const isInvited = computed((): boolean => {
/**
* This component's captcha configuration.
*/
const captchaConfig = computed((): MultiCaptchaConfig => {
return configStore.state.config.captcha.registration;
const captchaConfig = computed((): MultiCaptchaConfig | undefined => {
return configStore.state.config.captcha?.registration;
});

/**
Expand Down Expand Up @@ -496,11 +496,6 @@ async function detectBraveBrowser(): Promise<boolean> {
}

onBeforeMount(async () => {
if (!configStore.state.config.newSignupFlowEnabled) {
location.replace(RouteConfig.Register.path);
return;
}

if (route.query.partner) {
partner.value = route.query.partner.toString();
}
Expand All @@ -522,4 +517,14 @@ watch(password, () => {
repPasswordField.value?.validate();
}
});

watch(() => configStore.state.config, (value, oldValue) => {
if (value === oldValue) {
return;
}
if (!value.newSignupFlowEnabled) {
location.replace(RouteConfig.Register.path);
return;
}
});
</script>

0 comments on commit f502f50

Please sign in to comment.