session

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSessionName = "_session_"
)

Variables

This section is empty.

Functions

func GetSession

func GetSession(ctx *gin.Context) sessions.Session

func GetStore

func GetStore() sessions.Store

func Login

func Login(c *gin.Context, user *User)

func Logout

func Logout(c *gin.Context)

Types

type User

type User struct {
	UserID        int                    `json:"uid"`
	IsOwner       bool                   `json:"is_owner"`
	UserName      string                 `json:"user_name"`
	RoleID        int                    `json:"role_id"`
	Token         string                 `json:"token"`
	LoginAt       time.Time              `json:"login_at"`
	LoginDuration time.Duration          `json:"login_duration"`
	ExpiresAt     time.Time              `json:"expires_at"`
	AreaID        uint64                 `json:"area_id"`
	Option        map[string]interface{} `json:"option"`
}

func Get

func Get(c *gin.Context) *User

Get 根据token或cookie获取用户数据

func GetUserByToken

func GetUserByToken(c *gin.Context) *User

func (User) BelongsToArea

func (u User) BelongsToArea(areaID uint64) bool

Jump to

Keyboard shortcuts

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