models

package
v0.0.0-...-094dd3f Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NoSessionUser    = errors.New("no user in session")
	FailedAssertUser = errors.New("failed to assert user from session")
)

Functions

func RemoveUserFromSession

func RemoveUserFromSession(r *http.Request, w http.ResponseWriter, gs sessions.Store) error

func UserSignedIn

func UserSignedIn(ctx context.Context) bool

Types

type ModelCtxKey

type ModelCtxKey string
const (
	UserCtxKey ModelCtxKey = "user"
)

type User

type User struct {
	Id, Name, Email string
}

func NewUser

func NewUser() *User

func UserFromCtx

func UserFromCtx(ctx context.Context) User

func UserFromSession

func UserFromSession(r *http.Request, gs sessions.Store) (User, error)

func (*User) SaveToSession

func (u *User) SaveToSession(r *http.Request, w http.ResponseWriter, gs sessions.Store) error

func (*User) SetEmail

func (u *User) SetEmail(email string) *User

func (*User) SetId

func (u *User) SetId(userId string) *User

func (*User) SetName

func (u *User) SetName(name string) *User

Jump to

Keyboard shortcuts

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