fix: thorw on invalid token body

This commit is contained in:
Eli Bosley
2025-01-23 16:23:56 -05:00
parent 336478c2e0
commit 1e6fb7e3e3

View File

@@ -30,7 +30,6 @@ const getInputFields = (): {
const enterCallbackTokenIntoField = (token: string) => {
const { form, passwordField, usernameField } = getInputFields();
console.trace(passwordField, usernameField, form);
if (!passwordField || !usernameField || !form) {
console.warn('Could not find form, username, or password field');
} else {
@@ -87,6 +86,9 @@ onMounted(async () => {
});
if (token.ok) {
const tokenBody = await token.json();
if (!tokenBody.access_token) {
throw new Error('Token body did not contain access_token');
}
enterCallbackTokenIntoField(tokenBody.access_token);
if (window.location.search) {
window.history.replaceState({}, document.title, window.location.pathname);