auth

package
v0.8.14 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CookieName   = "_user"
	CookiePath   = "/"
	CookieMaxAge = 3600
)
View Source
var (
	UserLifetime int64 = 3600
	Guest              = &User{}
)

Functions

func Signin

func Signin(user encoder, w http.ResponseWriter) error

Signin write user encoded string into cookie

func Signout

func Signout(w http.ResponseWriter)

Signout setcookie with empty

Types

type User

type User struct {
	UID        string `json:"uid" msg:"u"`
	Name       string `json:"name" msg:"n"`
	Privileges string `json:"privileges,omitempty" msg:"p"`
	LastHit    int64  `json:"hit,omitempty" msg:"h"`
	TeamID     int    `json:"tid,omitempty" msg:"t"`
}

User 在线用户

func FromStaff

func FromStaff(staff staff) *User

func UserFromRequest

func UserFromRequest(r *http.Request) (user *User, err error)

UserFromRequest get user from cookie

func (*User) Decode

func (u *User) Decode(s string) (err error)

func (User) Encode

func (u User) Encode() (s string, err error)

func (*User) IsExpired

func (u *User) IsExpired() bool

func (*User) MarshalMsg

func (z *User) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*User) Msgsize

func (z *User) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*User) NeedRefresh

func (u *User) NeedRefresh() bool

func (*User) Refresh

func (u *User) Refresh()

refresh lastHit to time Unix

func (*User) Signin

func (user *User) Signin(w http.ResponseWriter) error

Signin call Signin for login

func (*User) UnmarshalMsg

func (z *User) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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