add backend tpl

This commit is contained in:
Rogee
2024-11-28 23:18:11 +08:00
parent 77e962b668
commit f7d95418a2
86 changed files with 3229 additions and 135 deletions

20
backend/common/jwt.go Executable file
View File

@@ -0,0 +1,20 @@
package common
import (
"github.com/atom-providers/jwt"
"github.com/gofiber/fiber/v2"
)
func GetJwtToken(ctx *fiber.Ctx) (string, error) {
headers, ok := ctx.GetReqHeaders()[jwt.HttpHeader]
if !ok {
return "", ctx.SendStatus(fiber.StatusUnauthorized)
}
if len(headers) == 0 {
return "", ctx.SendStatus(fiber.StatusUnauthorized)
}
token := headers[0]
token = token[len(jwt.TokenPrefix):]
return token, nil
}