mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-04-15 22:14:04 -04: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 {
|
||||
o.lock.Lock()
|
||||
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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue