commit 09ff06c821d7546e3f11254adcd76fea786344be
parent 2c8f558cae0e066a68ba74c40771c72a0230851b
Author: MTRNord <mtrnord1@gmail.com>
Date: Tue, 10 Apr 2018 21:06:44 +0200
If we have no string as type don't say we are authenticated as the session is broken in that case
Diffstat:
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/api/login/twitter.go b/api/login/twitter.go
@@ -182,14 +182,19 @@ func IsAuthenticatedHandleFunc(w http.ResponseWriter, req *http.Request) {
return
}
twitterUserID := Reqsession.Values[sessionUserKey]
- // We know this is a string
- uuidS, err := getUserUUID(twitterUserID.(string))
- if err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
- return
+ switch twitterUserID.(type) {
+ case string:
+ // We know this is a string
+ uuidS, err := getUserUUID(twitterUserID.(string))
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ w.Header().Set("UUID", uuidS)
+ w.WriteHeader(http.StatusOK)
}
- w.Header().Set("UUID", uuidS)
- w.WriteHeader(http.StatusOK)
+
+ w.WriteHeader(http.StatusUnauthorized)
} else {
w.WriteHeader(http.StatusUnauthorized)
}