Documentation
¶
Index ¶
- Constants
- Variables
- func ChangePassword(uid string, password string) error
- func CheckAuth(username, password string) bool
- func CheckPassword(username string, password string) (string, error)
- func CreateUserAndProfile(user *User, profile *Profile) error
- func GenerateVerifyCode() string
- func GetDepAndOrgByOrgId(orgId int) (string, string, error)
- func InsertCode(code string) string
- func LoginJWTSubKey(username string) string
- func LoginTicketJWTSubKey(username string) string
- func LoginTicketKey(username string) string
- func LoginTokenKey(username string) string
- func RegisterJWTSubKey(username string) string
- func RegisterTicketKey(ticket string) string
- func ResetPwdJWTSubKey(username string) string
- func SendEmail(recipient, content, title string) error
- func UpdateAvatar(avatar string, userId uint) error
- func UpdateGithubId(username string, githubId string) error
- func UpdateProfile(oldProfile, newProfile *Profile) error
- func VerifyCodeKey(username string) string
- type Auth
- type CheckRes
- type Organize
- type PostgresConf
- type Profile
- type RedisConf
- type User
Constants ¶
View Source
const ( REGISTER_TICKET_EXP = time.Minute * 5 RESETPWD_TICKET_EXP = time.Minute * 6 VERIFY_CODE_EXP = time.Minute * 3 // This is not login token expire time, this is login ticket expire time LOGIN_TICKET_EXP = time.Minute * 5 // This is login token expire time LOGIN_TOKEN_EXP = time.Hour * 24 * 7 // Login token key in redis LOGIN_TOKEN_IN_REDIS = "LOGIN" // For JWT LOGIN_TOKEN_SUB = "loginToken" LOGIN_TICKET_SUB = "loginTicket" REGIST_TICKET_SUB = "registerTicket" RESETPWD_TICKET_SUB = "resetPwdTicket" )
View Source
const VerifyCodeTemplate = `` /* 3238-byte string literal not displayed */
Variables ¶
View Source
var ( Db *gorm.DB Rdb *redis.Client RedisCtx = context.Background() )
View Source
var (
VERIFY_STATUS = map[string]string{
"VERIFY_ACCOUNT": "0",
"SEND_EMAIL": "1",
"VERIFY_CAPTCHA": "2",
"SUCCESS": "3",
}
)
Functions ¶
func ChangePassword ¶
func CreateUserAndProfile ¶
func GenerateVerifyCode ¶
func GenerateVerifyCode() string
func InsertCode ¶
func LoginJWTSubKey ¶
func LoginTicketJWTSubKey ¶
func LoginTicketKey ¶
func LoginTokenKey ¶
func RegisterJWTSubKey ¶
func RegisterTicketKey ¶
func ResetPwdJWTSubKey ¶
func UpdateAvatar ¶
func UpdateGithubId ¶
Add github id to user
func UpdateProfile ¶
func VerifyCodeKey ¶
Types ¶
type PostgresConf ¶
Postgres config
type Profile ¶
type Profile struct { ID uint `json:"id" gorm:"primaryKey"` UserID *uint `json:"user_id" gorm:"not null"` Nickname *string `json:"nickname" gorm:"not null"` Email *string `json:"email" gorm:"not null"` IsDeleted bool `json:"is_deleted" gorm:"not null"` Avatar *string `json:"avatar" gorm:"not null"` OrgId int `json:"org_id"` Bio *string `json:"bio"` Link pq.StringArray `json:"link" gorm:"type:varchar[]"` Badge *badge `json:"badge,omitempty" gorm:"type:json"` Hide pq.StringArray `json:"hide,omitempty" gorm:"type:varchar(30)[]"` }
func SelectProfileByUid ¶
type User ¶
type User struct { ID uint `json:"id,omitempty" gorm:"primaryKey"` Uid *string `json:"uid,omitempty" gorm:"not null"` Email *string `json:"email,omitempty" gorm:"not null"` Password *string `json:"password,omitempty" gorm:"not null"` QQId *string `json:"qq_id,omitempty"` LarkId *string `json:"lark_id,omitempty"` GithubId *string `json:"github_id,omitempty"` WechatId *string `json:"wechat_id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty" gorm:"not null"` IsDeleted bool `json:"is_deleted,omitempty" gorm:"not null"` }
func FindUserByGithubId ¶
Find user by github id Use it need to check if the user is nil Since the RecordNotFound error is nil
func GetUserByEmail ¶
GetUserByEmail find user by email
func GetUserByUid ¶
CheckUserByUid find user by uid return true if user exist
Source Files
¶
Click to show internal directories.
Click to hide internal directories.