photoprism/internal/query/sessions.go
Michael Mayer f5a8c5a45d Auth: Session and ACL enhancements #98 #1746
Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-09-28 09:01:17 +02:00

25 lines
512 B
Go

package query
import (
"time"
"github.com/photoprism/photoprism/internal/entity"
)
// Sessions returns stored sessions.
func Sessions() (result entity.Sessions, err error) {
err = Db().
Table(entity.Session{}.TableName()).
Select("*").
Where("expires_at > ?", time.Now()).
Scan(&result).Error
return result, err
}
// Session finds an existing session by id.
func Session(id string) (result entity.Session, err error) {
err = Db().Where("id = ?", id).First(&result).Error
return result, err
}