Removed debugging fmts, made localStorage clear on a login

This commit is contained in:
Tracker-Friendly 2024-10-15 20:33:35 +01:00
parent 2210185f33
commit 6bc7e887e0
2 changed files with 2 additions and 8 deletions

View File

@ -2,7 +2,6 @@ package main
import ( import (
"errors" "errors"
"fmt"
"net/url" "net/url"
"time" "time"
@ -357,14 +356,12 @@ func Main(information library.ServiceInitializationInformation) *chi.Mux {
sub, username, err := getUsername(commentData.JwtToken, oauthHostName, publicKey) sub, username, err := getUsername(commentData.JwtToken, oauthHostName, publicKey)
if err != nil { if err != nil {
renderJSON(400, w, map[string]interface{}{"error": "Invalid JWT token"}, information) renderJSON(400, w, map[string]interface{}{"error": "Invalid JWT token"}, information)
fmt.Println(err)
return return
} }
subBytes, err := uuid.MustParse(sub).MarshalBinary() subBytes, err := uuid.MustParse(sub).MarshalBinary()
if err != nil { if err != nil {
renderJSON(500, w, map[string]interface{}{"error": "Internal server error", "code": "10"}, information) renderJSON(500, w, map[string]interface{}{"error": "Internal server error", "code": "10"}, information)
fmt.Println(err)
return return
} }
@ -385,7 +382,6 @@ func Main(information library.ServiceInitializationInformation) *chi.Mux {
_, err = conn.DB.Exec("INSERT INTO comments (id, rfcId, rfcYear, content, creator, creatorName, created) VALUES ($1, $2, $3, $4, $5, $6, $7)", commentIdBytes, commentData.RfcId, commentData.RfcYear, commentData.Content, subBytes, username, time.Now().Unix()) _, err = conn.DB.Exec("INSERT INTO comments (id, rfcId, rfcYear, content, creator, creatorName, created) VALUES ($1, $2, $3, $4, $5, $6, $7)", commentIdBytes, commentData.RfcId, commentData.RfcYear, commentData.Content, subBytes, username, time.Now().Unix())
if err != nil { if err != nil {
renderJSON(500, w, map[string]interface{}{"error": "Internal server error", "code": "13"}, information) renderJSON(500, w, map[string]interface{}{"error": "Internal server error", "code": "13"}, information)
fmt.Println(err)
return return
} }

View File

@ -41,11 +41,9 @@ func randomChars(length int) (string, error) {
} }
func main() { func main() {
// Redirect to rfc if already logged in // Clear local storage
localStorage := js.Global().Get("localStorage") localStorage := js.Global().Get("localStorage")
if !localStorage.Call("getItem", "SECRET-token").IsNull() { localStorage.Call("clear")
js.Global().Get("window").Get("location").Call("replace", "/rfc")
}
statusBox := js.Global().Get("document").Call("getElementById", "statusBox") statusBox := js.Global().Get("document").Call("getElementById", "statusBox")
tryAgain := js.Global().Get("document").Call("getElementById", "tryAgain") tryAgain := js.Global().Get("document").Call("getElementById", "tryAgain")