1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-22 11:02:27 +00:00

Add error to SessionExist interface

Implement changed interface for all default providers as well and change
tests accordingly
This commit is contained in:
Phillip Stagnet
2020-08-03 13:31:49 +02:00
parent 9e1346ef4d
commit 28e6b3b924
14 changed files with 109 additions and 48 deletions

View File

@ -68,7 +68,7 @@ func (p *Provider) SessionRead(sid string) (session.Store, error) {
}
// SessionExist judged whether sid is exist in session
func (p *Provider) SessionExist(sid string) bool {
func (p *Provider) SessionExist(sid string) (bool, error) {
if p.client == nil {
if err := p.connectInit(); err != nil {
panic(err)
@ -76,12 +76,12 @@ func (p *Provider) SessionExist(sid string) bool {
}
value, err := p.client.Get(sid)
if err != nil {
panic(err)
return false, err
}
if value == nil || len(value.(string)) == 0 {
return false
return false, nil
}
return true
return true, nil
}
// SessionRegenerate regenerate session with new sid and delete oldsid