i wanted to add full cahce but i dont have time :(

This commit is contained in:
gitGnome
2026-03-26 14:21:30 +01:00
parent ca0b85cdb7
commit 4ccaf627b4
3 changed files with 37 additions and 18 deletions
+9 -18
View File
@@ -88,33 +88,24 @@ func HttpHandleLogin(response http.ResponseWriter, request *http.Request) {
return
}
var client = Client{Name: username}
if len(client.Name) < 8 {
if len(username) < 8 {
http.Error(response, "no or short password", http.StatusBadRequest)
return
}
ctx := request.Context()
var (
clientId uint32
err error
ctx = request.Context()
)
err := DbSetClientByName(ctx, &client)
clientId, err = CacheGetIdByName(username)
if err != nil {
http.Error(response, "bad login", http.StatusUnauthorized)
return
}
clientId, err = DbGetIdByClientName(ctx, username)
if err != nil {
_, err = CacheGetClientById(client.Id)
if err == nil {
otherLoggedIn, err := CacheGetClientById(client.Id)
if err == nil {
otherLoggedIn.WsConn.CloseNow()
}
}
token, err := TokenCreate(client.Id)
if err != nil {
http.Error(response, "internal server error", http.StatusInternalServerError)
}
response.Write([]byte(token))
}
func HttpHandleGroupCreate(response http.ResponseWriter, request *http.Request) {