Documentation ¶
Index ¶
- Variables
- func BindEmail(userId int64, email string) (err error)
- func BindEmailUserTo(toUserId, userId int64) (err error)
- func BindPhone(userId int64, phone string) (err error)
- func BindPhoneUserTo(toUserId, userId int64) (err error)
- func BindQQ(userId int64, openid string) (err error)
- func BindQQUserTo(toUserId, userId int64) (err error)
- func BindWechat(userId int64, openid string) (err error)
- func BindWechatUserTo(toUserId, userId int64) (err error)
- func BindWeibo(userId int64, openid string) (err error)
- func BindWeiboUserTo(toUserId, userId int64) (err error)
- func EncryptPassword(password, salt []byte) []byte
- func NewPasswordTag() string
- func NewSalt() []byte
- func SetNickname(userId int64, nickname string) (err error)
- func SetPassword(userId int64, password, salt []byte) (err error)
- func UnbindEmail(userId int64) (err error)
- func UnbindPhone(userId int64) (err error)
- func UnbindQQ(userId int64) (err error)
- func UnbindWechat(userId int64) (err error)
- func UnbindWeibo(userId int64) (err error)
- func UpdateEmail(userId int64, email string) (err error)
- func UpdatePhone(userId int64, phone string) (err error)
- func UpdateQQ(userId int64, openid string) (err error)
- func UpdateWechat(userId int64, openid string) (err error)
- func UpdateWeibo(userId int64, openid string) (err error)
- func VerifyEmail(userId int64) (err error)
- func VerifyPhone(userId int64) (err error)
- func VerifyQQ(userId int64) (err error)
- func VerifyWechat(userId int64) (err error)
- func VerifyWeibo(userId int64) (err error)
- type BindType
- type User
- func AddByEmail(email, nickname string, password, salt []byte, timestamp int64) (user *User, err error)
- func AddByPhone(phone, nickname string, password, salt []byte, timestamp int64) (user *User, err error)
- func AddByQQ(openid, nickname string, timestamp int64) (user *User, err error)
- func AddByWechat(openid, nickname string, timestamp int64) (user *User, err error)
- func AddByWeibo(openid, nickname string, timestamp int64) (user *User, err error)
- func Get(userId int64) (user *User, err error)
- func GetByEmail(email string) (user *User, err error)
- func GetByPhone(phone string) (user *User, err error)
- func GetByQQ(openid string) (user *User, err error)
- func GetByWechat(openid string) (user *User, err error)
- func GetByWeibo(openid string) (user *User, err error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("item not found") // 所有的没有找到的都返回这个错误
View Source
var PasswordSalt = NewSalt() // 无主地 salt, 用于安全授权
Functions ¶
func BindEmailUserTo ¶
绑定邮箱新注册账户到指定账户, 密码以指定账户为准.
调用该函数前, 请确认: 1. toUserId != userId 2. toUserId 存在并且 verified 3. userId 存在并且没有 verified 4. toUserId 未绑定邮箱 5. userId 是邮箱新注册账户
func BindPhoneUserTo ¶
绑定手机新注册账户到指定账户, 密码以指定账户为准.
调用该函数前, 请确认: 1. toUserId != userId 2. toUserId 存在并且 verified 3. userId 存在并且没有 verified 4. toUserId 未绑定手机 5. userId 是手机新注册账户
func BindQQUserTo ¶
绑定QQ新注册账户到指定账户, 密码以指定账户为准.
调用该函数前, 请确认: 1. toUserId != userId 2. toUserId 存在并且 verified 3. userId 存在并且没有 verified 4. toUserId 未绑定QQ 5. userId 是QQ新注册账户
func BindWechatUserTo ¶
绑定微信新注册账户到指定账户, 密码以指定账户为准.
调用该函数前, 请确认: 1. toUserId != userId 2. toUserId 存在并且 verified 3. userId 存在并且没有 verified 4. toUserId 未绑定微信 5. userId 是微信新注册账户
func BindWeiboUserTo ¶
绑定微博新注册账户到指定账户, 密码以指定账户为准.
调用该函数前, 请确认: 1. toUserId != userId 2. toUserId 存在并且 verified 3. userId 存在并且没有 verified 4. toUserId 未绑定微博 5. userId 是微博新注册账户
func EncryptPassword ¶
func NewPasswordTag ¶
func NewPasswordTag() string
Types ¶
type User ¶
type User struct { Id int64 `json:"id" sqlx:"id"` Nickname string `json:"nickname" sqlx:"nickname"` BindTypes BindType `json:"bind_types" sqlx:"bind_types"` Password []byte `json:"password" sqlx:"password"` PasswordTag string `json:"password_tag" sqlx:"password_tag"` Salt []byte `json:"salt" sqlx:"salt"` CreateTime int64 `json:"create_time" sqlx:"create_time"` Verified bool `json:"verified" sqlx:"verified"` }
user 基本信息
func AddByEmail ¶
func AddByEmail(email, nickname string, password, salt []byte, timestamp int64) (user *User, err error)
通过 邮箱 注册一个账户.
如果 nickname 为空, 则默认为 email 校验码注册时, password, salt 可以为 nil 如果 timestamp == 0 则默认使用当前时间
func AddByPhone ¶
func AddByPhone(phone, nickname string, password, salt []byte, timestamp int64) (user *User, err error)
通过 手机 注册一个账户.
如果 nickname 为空, 则默认为 phone 校验码注册时, password, salt 可以为 nil 如果 timestamp == 0 则默认使用当前时间
func GetByEmail ¶
func GetByPhone ¶
func GetByWechat ¶
func GetByWeibo ¶
Source Files ¶
- add_email.go
- add_phone.go
- add_qq.go
- add_wechat.go
- add_weibo.go
- bind_email.go
- bind_email_to.go
- bind_phone.go
- bind_phone_to.go
- bind_qq.go
- bind_qq_to.go
- bind_wechat.go
- bind_wechat_to.go
- bind_weibo.go
- bind_weibo_to.go
- cache.go
- error.go
- get.go
- model.go
- password.go
- set.go
- unbind_email.go
- unbind_phone.go
- unbind_qq.go
- unbind_wechat.go
- unbind_weibo.go
- update.go
- verify_account.go
Click to show internal directories.
Click to hide internal directories.