Skip to content

Commit

Permalink
may have fixed the prod bug 2
Browse files Browse the repository at this point in the history
  • Loading branch information
AmeerArsala committed Jun 9, 2024
1 parent 4b0348f commit d0518e3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions frontend/src/scripts/updatestate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
apiKey
} from "$lib/data/stores";

import { retrieveAPIKey, idNotFound } from "$lib/data/datafunctions";
import { idNotFound, retrieveAPIKey, retrieveUserCoreID } from "$lib/data/datafunctions";

// when to update all major values (where 'major' is defined by whether the whole site will break without correctly setting these values)
export default async function updateAll() {
Expand Down Expand Up @@ -111,15 +111,15 @@ export async function updateAuthentication() {
authentication.setIsAuthenticated(response.data);

console.log("Authentication Fetched! Authenticated: " + authentication.isAuthenticated());
postAuthentication();
await postAuthentication();
} catch(error) {
console.error("ERROR FINDING OUT WHETHER USER IS AUTHENTICATED: " + error);

authentication.setIsAuthenticated(false);
}
}

function postAuthentication() {
async function postAuthentication() {
console.log("Post Authentication: Fetch core user ID if not registered");
if (!coreRegistration.isUserRegistered()) {
// Call the route to manifest the user
Expand All @@ -134,6 +134,11 @@ function postAuthentication() {
// activate the registration
coreRegistration.activateRegistration();
}

// Still fetch core user ID (implication is that the user is registered)
if (idNotFound(userCoreID.getAtom().get())) {
await retrieveUserCoreID();
}
}

export function updateAPIKey() {
Expand Down

0 comments on commit d0518e3

Please sign in to comment.