make login return id of user also

This commit is contained in:
gitGnome
2026-04-05 15:13:44 +02:00
parent f254a71ef8
commit f38b130c8f
2 changed files with 12 additions and 5 deletions
+7 -5
View File
@@ -466,15 +466,15 @@ func HttpHandleTokenNew(response http.ResponseWriter, request *http.Request) {
if err != nil {
user = &User{Name: username}
if err = DbUserGetByName(ctx, user); err != nil {
http.Error(response, "bad login1", http.StatusUnauthorized)
http.Error(response, "bad login", http.StatusUnauthorized)
return
}
if err = DbUserGetGroups(ctx, user); err != nil {
http.Error(response, "bad login1", http.StatusUnauthorized)
http.Error(response, "bad login", http.StatusUnauthorized)
return
}
if err = DbUserGetConnections(ctx, user); err != nil {
http.Error(response, "bad login1", http.StatusUnauthorized)
http.Error(response, "bad login", http.StatusUnauthorized)
return
}
CacheSaveUser(user)
@@ -482,7 +482,7 @@ func HttpHandleTokenNew(response http.ResponseWriter, request *http.Request) {
err = bcrypt.CompareHashAndPassword([]byte(user.PasswordHash), []byte(password))
if err != nil {
http.Error(response, "bad login2", http.StatusUnauthorized)
http.Error(response, "bad login", http.StatusUnauthorized)
return
}
@@ -492,8 +492,10 @@ func HttpHandleTokenNew(response http.ResponseWriter, request *http.Request) {
return
}
json, err := json2.Marshal(LoginReturn{Token: token, UserId: user.Id})
response.WriteHeader(http.StatusCreated)
response.Write([]byte(token))
response.Write([]byte(json))
}
func HttpHandeGroupCreate(response http.ResponseWriter, request *http.Request) {