mirror of https://github.com/rocboss/paopao-ce
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
707 B
34 lines
707 B
3 years ago
|
package middleware
|
||
|
|
||
|
import (
|
||
|
"github.com/gin-gonic/gin"
|
||
3 years ago
|
"github.com/rocboss/paopao-ce/internal/model"
|
||
|
"github.com/rocboss/paopao-ce/pkg/app"
|
||
|
"github.com/rocboss/paopao-ce/pkg/errcode"
|
||
3 years ago
|
)
|
||
|
|
||
|
func Priv() gin.HandlerFunc {
|
||
|
return func(c *gin.Context) {
|
||
|
if user, exist := c.Get("USER"); exist {
|
||
|
if userModel, ok := user.(*model.User); ok {
|
||
|
if userModel.Status == model.UserStatusNormal {
|
||
|
|
||
|
if userModel.Phone == "" {
|
||
|
response := app.NewResponse(c)
|
||
|
response.ToErrorResponse(errcode.AccountNoPhoneBind)
|
||
|
c.Abort()
|
||
|
return
|
||
|
}
|
||
|
|
||
|
c.Next()
|
||
|
return
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
response := app.NewResponse(c)
|
||
|
response.ToErrorResponse(errcode.UserHasBeenBanned)
|
||
|
c.Abort()
|
||
|
}
|
||
|
}
|