Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: conflict nsid when using explorer & studio & dashboard same time #56

Merged
merged 1 commit into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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