diff options
author | Emile <git@emile.space> | 2024-11-06 19:03:11 +0100 |
---|---|---|
committer | Emile <git@emile.space> | 2024-11-06 19:03:11 +0100 |
commit | 4740f26d28d3b2c9b10cdaaaf1618bcd4bba84fe (patch) | |
tree | 60745a59d01611865b0466948f313a2dd23531ee /src | |
parent | 2cfce5804aab60365709d1832adc1345e99247ff (diff) |
user updates
Diffstat (limited to 'src')
-rw-r--r-- | src/user.go | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/src/user.go b/src/user.go index 48bc299..d55c9d8 100644 --- a/src/user.go +++ b/src/user.go @@ -151,6 +151,7 @@ func (s *State) GetUserFromUsername(username string) (User, error) { } // Returns the bots belonging to the given user +// TODO(emile): Also fetch the bits and the archs for displaying in the single battle page. In order to do so, join in both those tables func (s *State) GetUserBotsUsername(username string) ([]Bot, error) { rows, err := s.db.Query("SELECT id, name, source FROM bots b LEFT JOIN user_bot_rel ub ON ub.bot_id = b.id WHERE ub.user_id=(SELECT id FROM users WHERE name=?)", username) defer rows.Close() @@ -222,9 +223,7 @@ func (s *State) GetAllUsers() ([]User, error) { func loginHandler(w http.ResponseWriter, r *http.Request) { switch r.Method { case "GET": - log.Println("GET /login") // define data - log.Println("[d] Defining breadcrumbs") data := map[string]interface{}{} data["version"] = os.Getenv("VERSION") data["pagelink1"] = Link{"login", "/login"} @@ -236,7 +235,6 @@ func loginHandler(w http.ResponseWriter, r *http.Request) { } // session foo - log.Println("[d] Getting session") session, _ := globalState.sessions.Get(r, "session") username := session.Values["username"] @@ -245,7 +243,6 @@ func loginHandler(w http.ResponseWriter, r *http.Request) { log.Printf("[d] Getting the user %s\n", username.(string)) user, err := UserGetUserFromUsername(username.(string)) if user.Name == "" { - log.Println("no user found") } else if err != nil { log.Println(err) msg := "Error: could not get the user for given username" @@ -257,14 +254,12 @@ func loginHandler(w http.ResponseWriter, r *http.Request) { } // display errors passed via query parameters - log.Println("[d] Getting previous results") queryres := r.URL.Query().Get("res") if queryres != "" { data["res"] = queryres } // get the template - log.Println("[d] Getting the template") t, err := template.ParseGlob(fmt.Sprintf("%s/*.html", templatesPath)) if err != nil { log.Printf("Error reading the template Path: %s/*.html", templatesPath) @@ -275,7 +270,6 @@ func loginHandler(w http.ResponseWriter, r *http.Request) { } // exec! - log.Println("[d] Executing the template") t.ExecuteTemplate(w, "login", data) case "POST": @@ -337,8 +331,6 @@ func registerHandler(w http.ResponseWriter, r *http.Request) { {Name: "login/", Target: "/login"}, } - log.Println(username) - if username != nil { data["logged_in"] = true } |