diff --git a/main.go b/main.go index 6e7084a..86a76a7 100644 --- a/main.go +++ b/main.go @@ -94,13 +94,17 @@ func logout(ctx *gin.Context) { func userConfig(ctx *gin.Context) { session := sessions.Default(ctx) - user := session.Get(SessionUser) + userSession := session.Get(SessionUser) // log.Println(user) - if user == nil { + if userSession == nil { ctx.JSON(http.StatusUnauthorized, gin.H{"error": "权限错误"}) return } - ctx.JSON(http.StatusOK, gin.H{"message": "获取配置成功", "user": user.(*User).Name}) + + user := userSession.(*User) + user.Config = map[string]string{"a": "b", "ocean-app-id": "dasdsa"} + + ctx.JSON(http.StatusOK, gin.H{"message": "获取配置成功", "user": user.Name, "config": user.Config}) } func main() { diff --git a/web/src/login.js b/web/src/login.js index d80f2ed..7ffef1f 100644 --- a/web/src/login.js +++ b/web/src/login.js @@ -33,8 +33,6 @@ class Login extends React.Component { form.append("user", user); form.append("pwd", pwd); axios.post("/api/login", form).then(value => { - console.log(value); - console.log("Cookies are ", document.cookie) ReactDom.render(, document.getElementById('root')) return }); diff --git a/web/src/namespaceSelect.js b/web/src/namespaceSelect.js index bccfc02..a7e3b6d 100644 --- a/web/src/namespaceSelect.js +++ b/web/src/namespaceSelect.js @@ -20,9 +20,11 @@ class NamespaceSelect extends React.Component { onDropdownVisibleChange = (open) => { if(open) { - var resp = axios.post("/api/user/config") + axios.post("/api/user/config").then( resp => { + console.log(resp.data); + } ); + - console.log(resp) } }