Skip to content

Commit

Permalink
fix: conflict nsid when using explorer & studio & dashboard same time (
Browse files Browse the repository at this point in the history
  • Loading branch information
nianiaJR authored Dec 13, 2021
1 parent 0cf1e79 commit d672f78
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions conf/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ logspath = "./logs/"
loglevel = "info"
uploadspath = "./uploads/"
sqlitedbfilepath = "./tasks.db"
sessionkey = "common-nisd"
8 changes: 4 additions & 4 deletions controllers/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func (this *DatabaseController) Connect() {
m["nsid"] = nsid
res.Data = nsid
this.Ctx.SetCookie("Secure", "true")
this.Ctx.SetCookie("SameSite", "None")
this.SetSession("nsid", nsid)
this.Ctx.SetCookie("SameSite", "Strict")
this.SetSession(beego.AppConfig.String("sessionkey"), nsid)

res.Message = "Login successfully"
} else {
Expand All @@ -65,7 +65,7 @@ func (this *DatabaseController) Home() {

func (this *DatabaseController) Disconnect() {
var res Response
nsid := this.GetSession("nsid")
nsid := this.GetSession(beego.AppConfig.String("sessionkey"))
if nsid != nil {
dao.Disconnect(nsid.(string))
}
Expand All @@ -78,7 +78,7 @@ func (this *DatabaseController) Disconnect() {
func (this *DatabaseController) Execute() {
var res Response
var params ExecuteRequest
nsid := this.GetSession("nsid")
nsid := this.GetSession(beego.AppConfig.String("sessionkey"))
if nsid == nil {
res.Code = -1
res.Message = "connection refused for lack of session"
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func main() {
*/
beego.BConfig.WebConfig.Session.SessionCookieLifeTime = 0
beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 60 * 60 * 24
beego.BConfig.WebConfig.Session.SessionName = "nsid"
beego.BConfig.WebConfig.Session.SessionName = beego.AppConfig.String("sessionkey")
beego.BConfig.WebConfig.Session.SessionOn = true

/*
Expand Down Expand Up @@ -66,7 +66,7 @@ func main() {
logs.SetLogFuncCall(true)
logs.SetLogFuncCallDepth(3)
logs.SetLevel(logLevel)
defer func(){
defer func() {
logs.GetBeeLogger().Flush()
}()

Expand Down

0 comments on commit d672f78

Please sign in to comment.