|
|
@ -9,24 +9,37 @@ 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()
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
c.Next()
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
response := app.NewResponse(c)
|
|
|
|
|
|
|
|
response.ToErrorResponse(errcode.UserHasBeenBanned)
|
|
|
|
|
|
|
|
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()
|
|
|
|
c.Next()
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
response := app.NewResponse(c)
|
|
|
|
|
|
|
|
response.ToErrorResponse(errcode.UserHasBeenBanned)
|
|
|
|
|
|
|
|
c.Abort()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
response := app.NewResponse(c)
|
|
|
|
|
|
|
|
response.ToErrorResponse(errcode.UserHasBeenBanned)
|
|
|
|
|
|
|
|
c.Abort()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|