service

package
v0.0.0-...-81f72a3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const LOGIN_ERR_KEY = "PaoPaoUserLoginErr"
View Source
const MAX_CAPTCHA_TIMES = 2
View Source
const MAX_LOGIN_ERR_TIMES = 10

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthRequest

type AuthRequest struct {
	Username string `json:"username" form:"username" binding:"required"`
	Password string `json:"password" form:"password" binding:"required"`
}

type ChangeAvatarReq

type ChangeAvatarReq struct {
	Avatar string `json:"avatar" form:"avatar" binding:"required"`
}

type ChangeNicknameReq

type ChangeNicknameReq struct {
	Nickname string `json:"nickname" form:"nickname" binding:"required"`
}

type ChangePasswordReq

type ChangePasswordReq struct {
	Password    string `json:"password" form:"password" binding:"required"`
	OldPassword string `json:"old_password" form:"old_password" binding:"required"`
}

type PhoneCaptchaReq

type PhoneCaptchaReq struct {
	Phone        string `json:"phone" form:"phone" binding:"required"`
	ImgCaptcha   string `json:"img_captcha" form:"img_captcha" binding:"required"`
	ImgCaptchaID string `json:"img_captcha_id" form:"img_captcha_id" binding:"required"`
}

type RegisterRequest

type RegisterRequest struct {
	Username string `json:"username" form:"username" binding:"required"`
	Password string `json:"password" form:"password" binding:"required"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(ctx *gin.Context) Service

func (*Service) CheckPassword

func (svc *Service) CheckPassword(password string) error

密码检查

func (*Service) CheckPhoneExist

func (svc *Service) CheckPhoneExist(uid int64, phone string) bool

检测手机号是否存在

func (*Service) CheckStatus

func (svc *Service) CheckStatus(user *model.User) bool

检测用户权限

func (*Service) CreateAttachment

func (svc *Service) CreateAttachment(attachment *model.Attachment) (*model.Attachment, error)

func (*Service) DoLogin

func (svc *Service) DoLogin(param *AuthRequest) (*model.User, error)

用户认证

func (*Service) EncryptPasswordAndSalt

func (svc *Service) EncryptPasswordAndSalt(password string) (string, string)

密码加密&生成salt

func (*Service) GetParamSign

func (svc *Service) GetParamSign(param map[string]interface{}, secretKey string) string

func (*Service) GetRandomAvatar

func (s *Service) GetRandomAvatar() string

func (*Service) GetSuggestUsers

func (svc *Service) GetSuggestUsers(keyword string) ([]string, error)

根据关键词获取用户推荐

func (*Service) GetUserByUsername

func (svc *Service) GetUserByUsername(username string) (*model.User, error)

func (*Service) GetUserInfo

func (svc *Service) GetUserInfo(param *AuthRequest) (*model.User, error)

获取用户信息

func (*Service) Register

func (svc *Service) Register(username, password string) (*model.User, error)

用户注册

func (*Service) UpdateUserInfo

func (svc *Service) UpdateUserInfo(user *model.User) error

更新用户信息

func (*Service) ValidPassword

func (svc *Service) ValidPassword(dbPassword, password, salt string) bool

检查密码是否一致

func (*Service) ValidUsername

func (svc *Service) ValidUsername(username string) error

验证用户

type UserPhoneBindReq

type UserPhoneBindReq struct {
	Phone   string `json:"phone" form:"phone" binding:"required"`
	Captcha string `json:"captcha" form:"captcha" binding:"required"`
}

Jump to

Keyboard shortcuts

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