different fix for scope problem

This commit is contained in:
martin-mfg
2026-01-06 12:13:21 +01:00
parent f8b5e00ffc
commit fb8dc8a440
3 changed files with 28 additions and 11 deletions
+8 -1
View File
@@ -6,7 +6,14 @@ const authenticate = async (code, privateAccess, userKey) => {
try {
const fullUrl = `https://${HOST}/api/authenticate?code=${code}&private_access=${privateAccess}&user_key=${userKey}`;
const result = await axios.post(fullUrl);
return result.data;
const { userId, needDowngrade } = result.data;
if (needDowngrade) {
console.info(
`User ${userId} needs downgrade from private to public access.`,
);
window.location.href = `https://${HOST}/api/downgrade?user_key=${userKey}`;
}
return userId;
} catch (error) {
console.error(error);
return '';