mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-11-18 11:36:17 +00:00
Update settings.tsx
This commit is contained in:
@@ -323,21 +323,22 @@ export function Settings() {
|
|||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
password: tokenPassword,
|
password: tokenPassword,
|
||||||
totp_code: totpEnabled ? tokenTotpCode : undefined,
|
totp_token: totpEnabled ? tokenTotpCode : undefined,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
throw new Error(data.message || "Failed to generate API token")
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(data.message || data.error || "Failed to generate API token")
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json()
|
|
||||||
setApiToken(data.token)
|
setApiToken(data.token)
|
||||||
setSuccess("API token generated successfully! Make sure to copy it now as you won't be able to see it again.")
|
setSuccess("API token generated successfully! Make sure to copy it now as you won't be able to see it again.")
|
||||||
setTokenPassword("")
|
setTokenPassword("")
|
||||||
setTokenTotpCode("")
|
setTokenTotpCode("")
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error("[v0] Token generation error:", err)
|
||||||
setError(err instanceof Error ? err.message : "Failed to generate API token")
|
setError(err instanceof Error ? err.message : "Failed to generate API token")
|
||||||
} finally {
|
} finally {
|
||||||
setGeneratingToken(false)
|
setGeneratingToken(false)
|
||||||
|
|||||||
Reference in New Issue
Block a user