This commit is contained in:
eson 2020-01-07 11:52:50 +08:00
parent d8f261382d
commit fd25da4ae1
3 changed files with 11 additions and 7 deletions

10
main.go
View File

@ -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() {

View File

@ -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(<SiderConfig userName={user}></SiderConfig>, document.getElementById('root'))
return
});

View File

@ -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)
}
}