complete group creation endpoint with auth and validation, change parameter and return pointer usage in some get func

This commit is contained in:
2026-03-13 09:56:08 +01:00
parent eeea54492b
commit bb1acfe38f
4 changed files with 52 additions and 27 deletions
+6 -6
View File
@@ -86,25 +86,25 @@ func isPassValid(ctx context.Context, id uint32, plainPassword string) bool {
return bcrypt.CompareHashAndPassword([]byte(controlHash), []byte(plainPassword)) == nil
}
func GetUserDataById(ctx context.Context, id uint32) (*User, error) {
func GetUserDataById(ctx context.Context, id uint32) (User, error) {
var user User
err := dbConnection.QueryRow(ctx, "SELECT id, name, pass_hash, color FROM users WHERE id = $1", id).
Scan(&user.Id, &user.Name, &user.Password, &user.Color)
if err != nil {
return &User{}, err
return User{}, err
}
user.IsPasswordHashed = true
return &user, nil
return user, nil
}
func GetUserDataByName(ctx context.Context, name string) (*User, error) {
func GetUserDataByName(ctx context.Context, name string) (User, error) {
var user User
err := dbConnection.QueryRow(ctx, "SELECT id, name, pass_hash, color FROM users WHERE name = $1", name).
Scan(&user.Id, &user.Name, &user.Password, &user.Color)
if err != nil {
return &User{}, err
return User{}, err
}
user.IsPasswordHashed = true
return &user, nil
return user, nil
}
func CreateChatGroupWithoutMembers(ctx context.Context, group *ChatGroup) (uint32, error) {