Documentation ¶
Index ¶
- Variables
- func ConnDB() error
- func ConnRedis() error
- func CountServices() int64
- func CountUsers() int64
- func CreateService(s *Service) error
- func CreateUser(u *User) error
- func DeleteService(id uint) error
- func GetSetting(key string, defaultValue ...string) (string, error)
- func GetUserSalt() string
- func IsEmailUsed(email string) bool
- func IsErrEmailAlreadyUsed(err error) bool
- func IsErrNameNotAllowed(err error) bool
- func IsErrUserAlreadyExist(err error) bool
- func IsServiceExist(name string) bool
- func IsUserExist(name string) bool
- func MustGetSetting(key string, defaultValue ...string) string
- func NewServiceTicket(service *Service, user *User) (string, error)
- func SetSetting(key, value string) error
- func UpdateService(s *Service) error
- func UpdateUserProfile(u *User) error
- func ValidateTicket(ticket string) (*User, *Service, bool)
- type ErrEmailAlreadyUsed
- type ErrNameNotAllowed
- type ErrUserAlreadyExist
- type Service
- type Setting
- type User
- func GetUserByEmail(email string) (*User, error)
- func GetUserByNickName(nickName string) (*User, error)
- func GetUsers(options ...int) []*User
- func MustGetUserByID(uid uint) *User
- func UserAuthenticate(email string, password string) (*User, error)
- func ValidateServiceTicket(service *Service, ticket string) (*User, bool)
- func VerifyUserActiveCode(code string) *User
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrBadCredential = errors.New("电子邮箱或密码错误")
View Source
var ErrServiceExists = errors.New("服务已存在")
View Source
var ErrUserNotFound = errors.New("用户不存在")
View Source
var ErrorServiceNotFound = errors.New("服务不存在")
Functions ¶
func IsErrEmailAlreadyUsed ¶
func IsErrNameNotAllowed ¶
func IsErrUserAlreadyExist ¶
func MustGetSetting ¶
func NewServiceTicket ¶
NewServiceTicket 生成一个 Ticket。
func SetSetting ¶
Types ¶
type ErrEmailAlreadyUsed ¶
type ErrEmailAlreadyUsed struct {
// contains filtered or unexported fields
}
func (ErrEmailAlreadyUsed) Error ¶
func (err ErrEmailAlreadyUsed) Error() string
type ErrNameNotAllowed ¶
type ErrNameNotAllowed struct {
// contains filtered or unexported fields
}
func (ErrNameNotAllowed) Error ¶
func (err ErrNameNotAllowed) Error() string
type ErrUserAlreadyExist ¶
type ErrUserAlreadyExist struct {
// contains filtered or unexported fields
}
func (ErrUserAlreadyExist) Error ¶
func (err ErrUserAlreadyExist) Error() string
type Service ¶
type Service struct { gorm.Model Name string Avatar string // 服务 Logo Domain string // 白名单域名 Ban bool // 是否封禁 }
Service 为接入的服务。
func GetServiceByID ¶
GetServiceByID 根据对应的 ServiceID 查找对应的服务。
func GetServices ¶
GetServices 批量获取服务。 options[0] offset options[1] limit
func ServiceByURL ¶
ServiceByURL 通过 ServiceURL 查找对应的服务。
type User ¶
type User struct { gorm.Model NickName string Email string Password string Salt string Avatar string IsActive bool IsAdmin bool }
User 为用户表。
func GetUserByEmail ¶
GetUserByEmail 根据给定的电子邮箱地址查询对应的用户。
func GetUserByNickName ¶
GetUserByNickName 根据给定的用户昵称查询对应的用户。
func UserAuthenticate ¶
UserAuthenticate 验证用户传入的用户名与密码。
func ValidateServiceTicket ¶
ValidateServiceTicket 验证 Ticket 是否正确。
func VerifyUserActiveCode ¶
VerifyUserActiveCode 检查用户输入的账号激活码是否有效。
func (*User) GetActivationCode ¶
GetActivationCode 返回用户账号激活码,有效期两小时。
func (*User) ValidatePassword ¶
ValidatePassword 检查输入的密码是否正确。
Click to show internal directories.
Click to hide internal directories.