#8 add view and api to track activities

This commit is contained in:
Tim
2024-07-27 21:10:31 +02:00
parent 75f5ff2856
commit 8e4ef0c27a
12 changed files with 625 additions and 54 deletions

View File

@@ -13,6 +13,11 @@ const TOKEN_KEY ContextKey = "token"
func EnsureAuth(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
tokenStr := r.Header.Get("Authorization")
if (tokenStr == "") || (len(tokenStr) < len("Bearer ")) {
http.Error(w, "Unauthorized", http.StatusUnauthorized)
return
}
tokenStr = tokenStr[len("Bearer "):]
token, err := utils.VerifyToken(tokenStr)