complete group creation endpoint with auth and validation, change parameter and return pointer usage in some get func
This commit is contained in:
+6
-6
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user