mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
login: regenerates session id on login
This commit is contained in:
parent
f547c93a4f
commit
1e5778174c
@ -143,6 +143,7 @@ func loginUserWithUser(user *m.User, c *middleware.Context) {
|
|||||||
c.SetSuperSecureCookie(user.Rands+user.Password, setting.CookieRememberName, user.Login, days, setting.AppSubUrl+"/")
|
c.SetSuperSecureCookie(user.Rands+user.Password, setting.CookieRememberName, user.Login, days, setting.AppSubUrl+"/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.Session.RegenerateId(c)
|
||||||
c.Session.Set(middleware.SESS_KEY_USERID, user.Id)
|
c.Session.Set(middleware.SESS_KEY_USERID, user.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +103,8 @@ type SessionStore interface {
|
|||||||
Destory(*Context) error
|
Destory(*Context) error
|
||||||
// init
|
// init
|
||||||
Start(*Context) error
|
Start(*Context) error
|
||||||
|
// RegenerateId regenerates the session id
|
||||||
|
RegenerateId(*Context) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type SessionWrapper struct {
|
type SessionWrapper struct {
|
||||||
@ -116,6 +118,12 @@ func (s *SessionWrapper) Start(c *Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *SessionWrapper) RegenerateId(c *Context) error {
|
||||||
|
var err error
|
||||||
|
s.session, err = s.manager.RegenerateId(c.Context)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (s *SessionWrapper) Set(k interface{}, v interface{}) error {
|
func (s *SessionWrapper) Set(k interface{}, v interface{}) error {
|
||||||
if s.session != nil {
|
if s.session != nil {
|
||||||
return s.session.Set(k, v)
|
return s.session.Set(k, v)
|
||||||
|
Loading…
Reference in New Issue
Block a user