forked from gitea/gitea
Use Get/Set instead of Rename when Regenerate session id (#23975)
Do not use Rename here, because the old sid and new sid may be in different redis cluster slot. Fix #23869
This commit is contained in:
parent
26a0cd7143
commit
97d5ec2aeb
|
@ -183,16 +183,21 @@ func (p *RedisProvider) Regenerate(oldsid, sid string) (_ session.RawStore, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = p.c.Rename(graceful.GetManager().HammerContext(), poldsid, psid).Err(); err != nil {
|
// do not use Rename here, because the old sid and new sid may be in different redis cluster slot.
|
||||||
return nil, err
|
kvs, err := p.c.Get(graceful.GetManager().HammerContext(), poldsid).Result()
|
||||||
}
|
|
||||||
|
|
||||||
var kv map[interface{}]interface{}
|
|
||||||
kvs, err := p.c.Get(graceful.GetManager().HammerContext(), psid).Result()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = p.c.Del(graceful.GetManager().HammerContext(), poldsid).Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = p.c.Set(graceful.GetManager().HammerContext(), psid, kvs, p.duration).Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var kv map[interface{}]interface{}
|
||||||
if len(kvs) == 0 {
|
if len(kvs) == 0 {
|
||||||
kv = make(map[interface{}]interface{})
|
kv = make(map[interface{}]interface{})
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue