大面积重构

Response部分

usersController部分

中间件部分
This commit is contained in:
2022-04-06 13:54:48 +08:00
parent 513b563728
commit 0df2aaa82f
13 changed files with 114 additions and 119 deletions

View File

@@ -4,14 +4,23 @@ import (
"drive-linked/pkg/common"
"drive-linked/pkg/dto"
"github.com/kataras/iris/v12"
"strings"
)
func SignRequired(ctx iris.Context) {
auth := ctx.GetHeader("Authorization")
//TODO:更详细的判断,包括请求格式是否正确
// 取出Bearer后的内容
var tokenString string
if auths := strings.Split(auth, " "); len(auths) > 1 {
tokenString = auths[1]
} else {
ctx.Skip()
}
// 验证token
err := common.ValidateLogin(auth)
err := common.VerifyToken(tokenString)
if err == nil {
ctx.Values().Set("logged_in", true)
ctx.Next()