fix: JWT密钥YAML格式和401错误处理
- 修复JWT密钥在YAML配置文件中未加引号导致解析错误的问题 - 添加dashboard页面401错误处理,自动清除token并跳转登录页
This commit is contained in:
@@ -299,7 +299,7 @@ func generateConfigFile(dbType string, req SetupRequest, jwtSecret string) strin
|
|||||||
content.WriteString(" name: verification-platform\n")
|
content.WriteString(" name: verification-platform\n")
|
||||||
content.WriteString(" env: production\n")
|
content.WriteString(" env: production\n")
|
||||||
content.WriteString(" port: \"8080\"\n")
|
content.WriteString(" port: \"8080\"\n")
|
||||||
content.WriteString(fmt.Sprintf(" jwt_secret: %s\n", jwtSecret))
|
content.WriteString(fmt.Sprintf(" jwt_secret: \"%s\"\n", jwtSecret))
|
||||||
content.WriteString(" jwt_expire: 24h\n\n")
|
content.WriteString(" jwt_expire: 24h\n\n")
|
||||||
|
|
||||||
content.WriteString("# 数据库配置\n")
|
content.WriteString("# 数据库配置\n")
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ async function fetchDashboard() {
|
|||||||
const token = localStorage.getItem('token')
|
const token = localStorage.getItem('token')
|
||||||
if (!token) {
|
if (!token) {
|
||||||
console.error('No token found')
|
console.error('No token found')
|
||||||
|
router.push('/login')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,6 +155,13 @@ async function fetchDashboard() {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (response.status === 401) {
|
||||||
|
localStorage.removeItem('token')
|
||||||
|
localStorage.removeItem('user')
|
||||||
|
router.push('/login')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP error! status: ${response.status}`)
|
throw new Error(`HTTP error! status: ${response.status}`)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user