Browse Source

conform to renamed session method

cleanup
Lars Hoogestraat 7 months ago
parent
commit
dd32851030
5 changed files with 13 additions and 10 deletions
  1. +1
    -0
      database/database.go
  2. +1
    -1
      go.mod
  3. +2
    -0
      go.sum
  4. +5
    -5
      handler/account.go
  5. +4
    -4
      handler/user.go

+ 1
- 0
database/database.go View File

@ -142,5 +142,6 @@ func InitTables(db *sql.DB) error {
");"); err != nil {
return err
}
return nil
}

+ 1
- 1
go.mod View File

@ -4,7 +4,7 @@ go 1.15
require (
git.hoogi.eu/snafu/cfg v1.0.6
git.hoogi.eu/snafu/session v1.1.2
git.hoogi.eu/snafu/session v1.2.0
github.com/gorilla/csrf v1.7.0
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0


+ 2
- 0
go.sum View File

@ -2,6 +2,8 @@ git.hoogi.eu/snafu/cfg v1.0.6 h1:O34hYFqjwfnMjEwB4M8GaQQmBtf3H+AA0RFHb7PoMNs=
git.hoogi.eu/snafu/cfg v1.0.6/go.mod h1:LQolv8bqH8ZPz7h9PSVswdBXj1BIM+kW79AVS/jpE7A=
git.hoogi.eu/snafu/session v1.1.2 h1:MclTbSqD/9JodRUqFc4OwyJGk5AtonqB6BaG5RRJHf8=
git.hoogi.eu/snafu/session v1.1.2/go.mod h1:kgRDrnHcKc9H18G9533BXy6qO+81eBf6e9gkUzBMDuA=
git.hoogi.eu/snafu/session v1.2.0 h1:qmZXMCAZRrzcOOLsOltwPUeA4ckpjwjjJ8fQpFDSx+w=
git.hoogi.eu/snafu/session v1.2.0/go.mod h1:kgRDrnHcKc9H18G9533BXy6qO+81eBf6e9gkUzBMDuA=
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/chris-ramon/douceur v0.2.0 h1:IDMEdxlEUUBYBKE4z/mJnFyVXox+MjuEVDJNN27glkU=


+ 5
- 5
handler/account.go View File

@ -57,7 +57,7 @@ func AdminProfilePostHandler(ctx *middleware.AppContext, w http.ResponseWriter,
if len(u.PlainPassword) > 0 {
changePassword = true
// Password change
u.PlainPassword = []byte(r.FormValue("password"))
if !bytes.Equal(u.PlainPassword, []byte(r.FormValue("retyped_password"))) {
@ -81,11 +81,11 @@ func AdminProfilePostHandler(ctx *middleware.AppContext, w http.ResponseWriter,
session.SetValue("userid", u.ID)
sids := ctx.SessionService.SessionProvider.SessionIDsFromValues("userid", u.ID)
sessions := ctx.SessionService.SessionProvider.FindSessionsByValue("userid", u.ID)
for _, sid := range sids {
if sid != session.SessionID() {
ctx.SessionService.SessionProvider.Remove(sid)
for _, sid := range sessions {
if sid.SessionID() != session.SessionID() {
ctx.SessionService.SessionProvider.Remove(sid.SessionID())
}
}
}


+ 4
- 4
handler/user.go View File

@ -196,11 +196,11 @@ func AdminUserEditPostHandler(ctx *middleware.AppContext, w http.ResponseWriter,
}
}
sids := ctx.SessionService.SessionProvider.SessionIDsFromValues("userid", u.ID)
sessions := ctx.SessionService.SessionProvider.FindSessionsByValue("userid", u.ID)
for _, id := range sids {
if session.SessionID() != id {
ctx.SessionService.SessionProvider.Remove(id)
for _, s := range sessions {
if session.SessionID() != s.SessionID() {
ctx.SessionService.SessionProvider.Remove(s.SessionID())
}
}
}


Loading…
Cancel
Save