Reset api_key from env defaults on server select to clear stale keys
This commit is contained in:
@@ -143,21 +143,27 @@ const customUrl = ref('')
|
|||||||
const selectedUrl = ref('')
|
const selectedUrl = ref('')
|
||||||
|
|
||||||
function initSelectedServer() {
|
function initSelectedServer() {
|
||||||
|
// Reset api_key from env defaults to clear any stale key
|
||||||
|
localStorage.removeItem('portal_config')
|
||||||
const config = getCurrentConfig()
|
const config = getCurrentConfig()
|
||||||
const currentUrl = config.api_base_url
|
const currentUrl = config.api_base_url
|
||||||
const matched = serverPresets.find(s => s.url === currentUrl)
|
const matched = serverPresets.find(s => s.url === currentUrl)
|
||||||
if (matched) {
|
if (matched) {
|
||||||
selectedUrl.value = matched.url
|
selectedUrl.value = matched.url
|
||||||
showCustomUrl.value = false
|
showCustomUrl.value = false
|
||||||
|
saveConfig({ ...config, api_base_url: matched.url })
|
||||||
} else {
|
} else {
|
||||||
selectedUrl.value = currentUrl
|
selectedUrl.value = currentUrl
|
||||||
customUrl.value = currentUrl
|
customUrl.value = currentUrl
|
||||||
showCustomUrl.value = true
|
showCustomUrl.value = true
|
||||||
|
saveConfig({ ...config })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectServer(srv: ServerPreset) {
|
function selectServer(srv: ServerPreset) {
|
||||||
selectedUrl.value = srv.url
|
selectedUrl.value = srv.url
|
||||||
|
// Reset api_key from env to avoid using a stale key
|
||||||
|
localStorage.removeItem('portal_config')
|
||||||
const config = getCurrentConfig()
|
const config = getCurrentConfig()
|
||||||
saveConfig({ ...config, api_base_url: srv.url })
|
saveConfig({ ...config, api_base_url: srv.url })
|
||||||
}
|
}
|
||||||
@@ -178,6 +184,8 @@ function toggleCustom() {
|
|||||||
|
|
||||||
function onCustomUrlInput() {
|
function onCustomUrlInput() {
|
||||||
selectedUrl.value = customUrl.value
|
selectedUrl.value = customUrl.value
|
||||||
|
// Reset api_key from env
|
||||||
|
localStorage.removeItem('portal_config')
|
||||||
const config = getCurrentConfig()
|
const config = getCurrentConfig()
|
||||||
saveConfig({ ...config, api_base_url: customUrl.value })
|
saveConfig({ ...config, api_base_url: customUrl.value })
|
||||||
}
|
}
|
||||||
@@ -199,6 +207,7 @@ const handleLogin = async () => {
|
|||||||
let apiUrl = selectedUrl.value
|
let apiUrl = selectedUrl.value
|
||||||
if (showCustomUrl.value && customUrl.value) {
|
if (showCustomUrl.value && customUrl.value) {
|
||||||
apiUrl = customUrl.value
|
apiUrl = customUrl.value
|
||||||
|
localStorage.removeItem('portal_config')
|
||||||
const config = getCurrentConfig()
|
const config = getCurrentConfig()
|
||||||
saveConfig({ ...config, api_base_url: customUrl.value })
|
saveConfig({ ...config, api_base_url: customUrl.value })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user