session

package
v0.0.0-...-69a11cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2024 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotLoggedIn = &errors.UnauthorizedError{Reason: "not logged in"}
View Source
var ErrRedisConnectionDeSync = errors.New("redis connection de-synced")

Functions

This section is empty.

Types

type Data

type Data struct {
	AnonTokenAccess    anonTokenAccess           `json:"ata,omitempty"`
	PasswordResetToken oneTimeToken.OneTimeToken `json:"rt,omitempty"`
	PostLoginRedirect  string                    `json:"plr,omitempty"`
	LoginMetadata      *LoginMetadata            `json:"lm,omitempty"`
	PublicData
}

func (*Data) AddAnonTokenAccess

func (d *Data) AddAnonTokenAccess(projectId sharedTypes.UUID, token project.AccessToken)

func (*Data) GetAnonTokenAccess

func (d *Data) GetAnonTokenAccess(projectId sharedTypes.UUID) project.AccessToken

func (*Data) IsEmpty

func (d *Data) IsEmpty() bool

type Id

type Id string

type LoginMetadata

type LoginMetadata struct {
	IPAddress  string    `json:"i"`
	LoggedInAt time.Time `json:"t"`
}

type Manager

type Manager interface {
	DestroyAllForUser(ctx context.Context, userId sharedTypes.UUID) error
	GetSession(c *httpUtils.Context) (*Session, error)
	GetOrCreateSession(c *httpUtils.Context) (*Session, error)
	GetSessionById(ctx context.Context, id Id) (*Session, error)
	Flush(c *httpUtils.Context, session *Session) error
	RequireLoggedInSession(c *httpUtils.Context) (*Session, error)
	TouchSession(c *httpUtils.Context, session *Session)
}

func New

func New(options signedCookie.Options, client redis.UniversalClient) Manager

type OtherSessionsDetails

type OtherSessionsDetails struct {
	Sessions []LoginMetadata
	// contains filtered or unexported fields
}

type PublicData

type PublicData struct {
	User     *User  `json:"u,omitempty"`
	Language string `json:"l,omitempty"`
}

type Session

type Session struct {
	// contains filtered or unexported fields
}

func (*Session) CheckIsLoggedIn

func (s *Session) CheckIsLoggedIn() error

func (*Session) Destroy

func (s *Session) Destroy(ctx context.Context) error

func (*Session) DestroyOthers

func (s *Session) DestroyOthers(ctx context.Context, d *OtherSessionsDetails) error

func (*Session) GetOthers

func (s *Session) GetOthers(ctx context.Context) (*OtherSessionsDetails, error)

func (*Session) IsLoggedIn

func (s *Session) IsLoggedIn() bool

func (*Session) Login

func (s *Session) Login(ctx context.Context, u user.ForSession, ip string) (string, error)

func (*Session) PrepareLogin

func (s *Session) PrepareLogin(ctx context.Context, u user.ForSession, ip string) (string, func(), error)

func (*Session) Save

func (s *Session) Save(ctx context.Context) (bool, error)

func (*Session) Touch

func (s *Session) Touch(ctx context.Context) error

type User

type User struct {
	Email     sharedTypes.Email `json:"e"`
	FirstName string            `json:"f,omitempty"`
	Id        sharedTypes.UUID  `json:"i"`
	LastName  string            `json:"l,omitempty"`
}

func (*User) ToPublicUserInfo

func (u *User) ToPublicUserInfo() user.WithPublicInfo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL