photoprism/internal/session/session_public.go
Michael Mayer 323d495840 Auth: Apply user rights and permissions in the search API #98 #782
Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-09-30 00:42:19 +02:00

25 lines
538 B
Go

package session
import (
"github.com/photoprism/photoprism/internal/entity"
)
var Public *entity.Session
var PublicID = "234200000000000000000000000000000000000000000000"
// Public returns a client session for use in public mode.
func (s *Session) Public() *entity.Session {
if Public == nil {
// Do nothing.
} else if !Public.Expired() {
return Public
}
Public = entity.NewSession(s.expiresAfter)
Public.ID = PublicID
Public.AuthMethod = "public"
Public.SetUser(&entity.Admin)
Public.CacheDuration(-1)
return Public
}