Skip to content

Commit

Permalink
proper session path
Browse files Browse the repository at this point in the history
  • Loading branch information
f1mishutka committed Apr 9, 2024
1 parent 8b5576e commit 14608e4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/api_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,32 @@ func (r *apiRequest) HealthCheck() {

func (r *apiRequest) Password() {
if r.getInData("password") == Settings.GuiPassword {
r.setStatus("ok", "You are authorized!")

// Set user as authenticated
r.session.Clear()
r.session.Set("auth", true)

r.session.Options(sessions.Options{
MaxAge: 24 * 3600,
Path: "/",
})

r.session.Save()

r.setStatus("ok", "You are authorized!")
} else {
r.setStatus("danger", "Wrong password")
}
}

func (r *apiRequest) Logout() {
r.session.Clear()
r.session.Save()

r.session.Options(sessions.Options{
MaxAge: 0,
MaxAge: -1, //remove
Path: "/",
})

r.session.Save()

r.setStatus("info", "Good bye!")
}

Expand Down

0 comments on commit 14608e4

Please sign in to comment.