2022-09-28 09:01:17 +02:00
|
|
|
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 {
|
2022-09-30 00:42:19 +02:00
|
|
|
if Public == nil {
|
|
|
|
// Do nothing.
|
|
|
|
} else if !Public.Expired() {
|
2022-09-28 09:01:17 +02:00
|
|
|
return Public
|
|
|
|
}
|
|
|
|
|
2022-10-03 22:59:29 +02:00
|
|
|
Public = entity.NewSession(0, 0)
|
2022-09-28 09:01:17 +02:00
|
|
|
Public.ID = PublicID
|
2022-09-30 00:42:19 +02:00
|
|
|
Public.AuthMethod = "public"
|
2022-09-28 09:01:17 +02:00
|
|
|
Public.SetUser(&entity.Admin)
|
|
|
|
Public.CacheDuration(-1)
|
|
|
|
|
|
|
|
return Public
|
|
|
|
}
|