From 2604dae83c181f64aa3f2e603cd1d076d9640756 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 8 May 2024 09:49:58 +0100 Subject: [PATCH] Resolve eslint issues in new 2FA code /puter/src/UI/Settings/UITabSecurity.js 13:13 error 'user' is not defined no-undef 31:13 error 'user' is not defined no-undef 32:70 error 'user' is not defined no-undef 36:30 error 'user' is not defined no-undef 40:82 error 'user' is not defined no-undef 41:83 error 'user' is not defined no-undef 87:41 error 'api_origin' is not defined no-undef /puter/src/UI/UIWindow2FASetup.js 39:33 error 'api_origin' is not defined no-undef 51:37 error 'api_origin' is not defined no-undef 69:37 error 'api_origin' is not defined no-undef /puter/src/UI/UIWindowLogin.js 202:73 error 'api_origin' is not defined no-undef 271:73 error 'api_origin' is not defined no-undef --- src/UI/Settings/UITabSecurity.js | 3 ++- src/UI/UIWindow2FASetup.js | 6 +++--- src/UI/UIWindowLogin.js | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/UI/Settings/UITabSecurity.js b/src/UI/Settings/UITabSecurity.js index 65ccf5b4..7514b9ce 100644 --- a/src/UI/Settings/UITabSecurity.js +++ b/src/UI/Settings/UITabSecurity.js @@ -8,6 +8,7 @@ export default { icon: 'shield.svg', html: () => { let h = `

${i18n('security')}

`; + let user = window.user; // change password button if(!user.is_temp){ @@ -84,7 +85,7 @@ export default { ] }) if ( ! alert_resp ) return; - const resp = await fetch(`${api_origin}/auth/configure-2fa/disable`, { + const resp = await fetch(`${window.api_origin}/auth/configure-2fa/disable`, { method: 'POST', headers: { Authorization: `Bearer ${puter.authToken}`, diff --git a/src/UI/UIWindow2FASetup.js b/src/UI/UIWindow2FASetup.js index b76fafd9..d574f8d3 100644 --- a/src/UI/UIWindow2FASetup.js +++ b/src/UI/UIWindow2FASetup.js @@ -36,7 +36,7 @@ import UIComponentWindow from "./UIComponentWindow.js"; const UIWindow2FASetup = async function UIWindow2FASetup () { // FIRST REQUEST :: Generate the QR code and recovery codes - const resp = await fetch(`${api_origin}/auth/configure-2fa/setup`, { + const resp = await fetch(`${window.api_origin}/auth/configure-2fa/setup`, { method: 'POST', headers: { Authorization: `Bearer ${puter.authToken}`, @@ -48,7 +48,7 @@ const UIWindow2FASetup = async function UIWindow2FASetup () { // SECOND REQUEST :: Verify the code [first wizard screen] const check_code_ = async function check_code_ (value) { - const resp = await fetch(`${api_origin}/auth/configure-2fa/test`, { + const resp = await fetch(`${window.api_origin}/auth/configure-2fa/test`, { method: 'POST', headers: { Authorization: `Bearer ${puter.authToken}`, @@ -66,7 +66,7 @@ const UIWindow2FASetup = async function UIWindow2FASetup () { // FINAL REQUEST :: Enable 2FA [second wizard screen] const enable_2fa_ = async function check_code_ (value) { - const resp = await fetch(`${api_origin}/auth/configure-2fa/enable`, { + const resp = await fetch(`${window.api_origin}/auth/configure-2fa/enable`, { method: 'POST', headers: { Authorization: `Bearer ${puter.authToken}`, diff --git a/src/UI/UIWindowLogin.js b/src/UI/UIWindowLogin.js index 6c1ca26c..0885577a 100644 --- a/src/UI/UIWindowLogin.js +++ b/src/UI/UIWindowLogin.js @@ -199,7 +199,7 @@ async function UIWindowLogin(options){ let error_i18n_key = 'something_went_wrong'; if ( ! value ) return; try { - const resp = await fetch(`${api_origin}/login/otp`, { + const resp = await fetch(`${window.api_origin}/login/otp`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -268,7 +268,7 @@ async function UIWindowLogin(options){ let error_i18n_key = 'something_went_wrong'; if ( ! value ) return; try { - const resp = await fetch(`${api_origin}/login/recovery-code`, { + const resp = await fetch(`${window.api_origin}/login/recovery-code`, { method: 'POST', headers: { 'Content-Type': 'application/json',