register, login logic works

This commit is contained in:
2026-03-11 19:46:37 +01:00
parent 744dd7f42d
commit 58fc553f04
5 changed files with 177 additions and 1 deletions
+9
View File
@@ -1,6 +1,7 @@
package main
import (
"log"
"net/http"
"golang.org/x/crypto/bcrypt"
@@ -30,6 +31,14 @@ func RegisterHandler(response http.ResponseWriter, request *http.Request) {
}
if _, err := AddNewUser(ctx, User{0, username, password, "xxx", false}); err != nil {
http.Error(response, "Internal server error", http.StatusInternalServerError)
log.Fatal(err)
return
}
response.WriteHeader(http.StatusCreated)
_, err := response.Write([]byte("registered"))
if err != nil {
http.Error(response, "Internal server error", http.StatusInternalServerError)
return
}