nie wiedzieju

This commit is contained in:
GitProtogen
2026-03-18 12:07:29 +01:00
parent d3fc2a65d9
commit da5f87d67b
6 changed files with 36 additions and 19 deletions
+7 -1
View File
@@ -32,6 +32,7 @@ func RegisterHandler(response http.ResponseWriter, request *http.Request) {
newClient := Client{
Name: username,
PasswordHash: password,
Color: [3]uint8{120, 120, 120}, //"xxx"
}
err := CreateClient(ctx, &newClient)
@@ -61,19 +62,24 @@ func LoginHandler(response http.ResponseWriter, request *http.Request) {
return
}
var client Client
id, err := GetIdFromClientName(ctx, username)
if err != nil {
http.Error(response, "bad login", http.StatusBadRequest)
return
}
err = CheckPassword(ctx, id, password)
err = DbGetClient(ctx)
if err != nil {
http.Error(response, "bad login", http.StatusBadRequest)
return
}
token, err := GetToken(id)
if err != nil {
http.Error(response, "Internal error", http.StatusInternalServerError)
return
}
response.Write([]byte(token))