mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
fix: only destroy session if exists
The virtual session doesn't unconditionally call `Read` of the provider, which means it's possible for a session to not exists (created by the call to `Read`). To avoid that the call to `Destroy` fails with that the session does not exists, do also the exists check for `Destroy`.
This commit is contained in:
parent
31fff54e17
commit
ea9f2a236b
1 changed files with 4 additions and 1 deletions
|
|
@ -76,7 +76,10 @@ func (o *VirtualSessionProvider) Exist(sid string) bool {
|
||||||
func (o *VirtualSessionProvider) Destroy(sid string) error {
|
func (o *VirtualSessionProvider) Destroy(sid string) error {
|
||||||
o.lock.Lock()
|
o.lock.Lock()
|
||||||
defer o.lock.Unlock()
|
defer o.lock.Unlock()
|
||||||
return o.provider.Destroy(sid)
|
if o.provider.Exist(sid) {
|
||||||
|
return o.provider.Destroy(sid)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regenerate regenerates a session store from old session ID to new one.
|
// Regenerate regenerates a session store from old session ID to new one.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue