From b6111a1f44d8684467172c8f93e74759ef9e5422 Mon Sep 17 00:00:00 2001 From: orcas Date: Thu, 4 Jul 2019 05:19:11 +0800 Subject: [PATCH] Validate token fields --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index cd3d00e..4226b88 100644 --- a/main.go +++ b/main.go @@ -87,6 +87,11 @@ func AuthMiddleware(next httprouter.Handle) httprouter.Handle { return } + if client.UserId == "" || ClientId == "" { + http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) + return + } + context := context.WithValue(r.Context(), "user", client) next(w, r.WithContext(context), p) }