Skip to content

Commit

Permalink
Merge pull request #999 from Onlineberatung/OB-FixRegistrationDirectLink
Browse files Browse the repository at this point in the history
feat: added fallback loader for non unique consulting type slugs
  • Loading branch information
web-mi authored Jan 28, 2024
2 parents 84d7466 + d52d261 commit 96a53e1
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ CSRF_WHITELIST_HEADER_FOR_LOCAL_DEVELOPMENT=X-WHITELIST-HEADER
# Disable 2FA
REACT_APP_DISABLE_2FA_DUTY=0

### Registration
# Enable fallback loader for direct link registration where slug could not be matched (0/1)
FRONTEND_REGISTRATION_DIRECTLINK_FALLBACKLOADER_ENABLED=

### Weblate
# Weblate host
FRONTEND_WEBLATE_HOST=
Expand Down
11 changes: 11 additions & 0 deletions proxy/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,16 @@ module.exports = {
disabled: process.env.FRONTEND_TRANSLATION_CACHE_DISABLED || true,
time: process.env.FRONTEND_TRANSLATION_CACHE_TIME || 30
}
},
registration: {
directlink: {
fallbackLoader: {
enabled: !!parseInt(
process.env
.FRONTEND_REGISTRATION_DIRECTLINK_FALLBACKLOADER_ENABLED ||
'1'
)
}
}
}
};
7 changes: 7 additions & 0 deletions src/globalState/interfaces/AppConfig/AppConfigInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ export interface AppConfigInterface extends AppSettingsInterface {
};
};
groupChat?: GroupChatConfig;
registration?: {
directlink?: {
fallbackLoader?: {
enabled?: boolean;
};
};
};
}

interface ReleaseToggles {
Expand Down
29 changes: 28 additions & 1 deletion src/utils/useUrlParamsLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,32 @@ export default function useUrlParamsLoader() {
)
) {
consultingType = null;

// Fallback logic for special client because slug is not unique. So try reversed logicc
if (
settings?.registration?.directlink
?.fallbackLoader?.enabled &&
consultingTypeSlug
) {
const loadConsultingType = async (id) => {
const ct = await apiGetConsultingType({
consultingTypeId: id
});
return ct.slug === consultingTypeSlug
? ct
: null;
};

for (const {
consultingType: ctId
} of consultant.agencies) {
const res = await loadConsultingType(ctId);
if (res) {
consultingType = res;
break;
}
}
}
}
}
}
Expand Down Expand Up @@ -131,7 +157,8 @@ export default function useUrlParamsLoader() {
consultantId,
topicIdOrName,
settings.multitenancyWithSingleDomainEnabled,
settings.urls.toRegistration
settings.urls.toRegistration,
settings?.registration?.directlink?.fallbackLoader?.enabled
]);

useEffect(() => {
Expand Down

0 comments on commit 96a53e1

Please sign in to comment.