|
|
@ -9,12 +9,12 @@ import (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func Priv() gin.HandlerFunc {
|
|
|
|
func Priv() gin.HandlerFunc {
|
|
|
|
enablePhoneBind := conf.CfgIf("PhoneBind")
|
|
|
|
if conf.CfgIf("PhoneBind") {
|
|
|
|
return func(c *gin.Context) {
|
|
|
|
return func(c *gin.Context) {
|
|
|
|
if user, exist := c.Get("USER"); exist {
|
|
|
|
if u, exist := c.Get("USER"); exist {
|
|
|
|
if userModel, ok := user.(*model.User); ok {
|
|
|
|
if user, ok := u.(*model.User); ok {
|
|
|
|
if userModel.Status == model.UserStatusNormal {
|
|
|
|
if user.Status == model.UserStatusNormal {
|
|
|
|
if enablePhoneBind && userModel.Phone == "" {
|
|
|
|
if user.Phone == "" {
|
|
|
|
response := app.NewResponse(c)
|
|
|
|
response := app.NewResponse(c)
|
|
|
|
response.ToErrorResponse(errcode.AccountNoPhoneBind)
|
|
|
|
response.ToErrorResponse(errcode.AccountNoPhoneBind)
|
|
|
|
c.Abort()
|
|
|
|
c.Abort()
|
|
|
@ -29,4 +29,17 @@ func Priv() gin.HandlerFunc {
|
|
|
|
response.ToErrorResponse(errcode.UserHasBeenBanned)
|
|
|
|
response.ToErrorResponse(errcode.UserHasBeenBanned)
|
|
|
|
c.Abort()
|
|
|
|
c.Abort()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return func(c *gin.Context) {
|
|
|
|
|
|
|
|
if u, exist := c.Get("USER"); exist {
|
|
|
|
|
|
|
|
if user, ok := u.(*model.User); ok && user.Status == model.UserStatusNormal {
|
|
|
|
|
|
|
|
c.Next()
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
response := app.NewResponse(c)
|
|
|
|
|
|
|
|
response.ToErrorResponse(errcode.UserHasBeenBanned)
|
|
|
|
|
|
|
|
c.Abort()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|