package middleware

import (
	"cc-officialweb/utils"
	"github.com/beego/beego/v2/core/logs"
	"github.com/beego/beego/v2/server/web/context"
)

func AuthMiddleware(ctx *context.Context) {
	authHeader := ctx.Request.Header.Get("Authorization")
	token, err := utils.ParseToken(authHeader)
	if err != nil {
		logs.Error(err)
		ctx.Output.SetStatus(401)
		ctx.Output.Body([]byte(err.Error()))
		return
	}
	logs.Info("Token:", token)
}
