session

package
v0.0.0-...-bf0c33e Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const CheckCodeMaxTimes = 3 // 校验码最多可以校验多少次

Variables

This section is empty.

Functions

func Add

func Add(sid string, ss *Session) (err error)

添加 sid-Session, 如果 sid 冲突则返回错误.

func CompareAndSwap

func CompareAndSwap(sid string, ss *Session) (err error)

设置 sid-Session, 该 Session 是通过 Get 获取的, 如果在 Get 之后该 sid 对应的 Session 发生改变, 则返回错误.

func Delete

func Delete(sid string) (err error)

删除 Session, 如果没有匹配则返回 errors.ErrNotFound.

func NewGuestSessionId

func NewGuestSessionId() (sid string, err error)

^temp\.[A-Za-z0-9_-]+$

func NewSessionId

func NewSessionId() (sid string, err error)

^[A-Za-z0-9_-]+$

func Set

func Set(sid string, ss *Session) (err error)

无条件设置 sid-Session

Types

type CheckCode

type CheckCode struct {
	Key   string `json:"key"`   // email, phone...
	Code  string `json:"code"`  // 校验码
	Times int    `json:"times"` // 已经校验的次数
}

type Session

type Session struct {
	TokenSignature string `json:"token_sign"`             // Token 签名; 安全考虑, 比对客户端传过来的 token 的签名部分
	UserId         int64  `json:"user_id,omitempty"`      // 当前用户
	PasswordTag    string `json:"password_tag,omitempty"` // 认证时的 password_tag, 对于 AuthType 是 AuthTypeEmailPassword, AuthTypePhonePassword 时有效

	EmailCheckCode *CheckCode `json:"email_checkcode,omitempty"` // 邮箱校验码
	PhoneCheckCode *CheckCode `json:"phone_checkcode,omitempty"` // 手机校验码
	OAuth2State    string     `json:"oauth2_state,omitempty"`    // 微信公众号 oauth 认证的 state
	// contains filtered or unexported fields
}

func Get

func Get(sid string) (ss *Session, err error)

获取 Session, 如果找不到返回 errors.ErrNotFound.

Jump to

Keyboard shortcuts

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