refactor(db): move users and persons functions into separate files

This commit is contained in:
2025-01-18 18:05:52 +03:00
parent 171ca5e52c
commit fbba2c035f
3 changed files with 274 additions and 270 deletions
+16
View File
@@ -0,0 +1,16 @@
package db
import "context"
func UserLogin(ctx context.Context, login, password string) (user_id string, err error) {
row := connPool.QueryRow(ctx, "SELECT id FROM users WHERE login=$1 AND password=crypt($2, password)", login, password)
err = row.Scan(&user_id)
return
}
func UserAuth(ctx context.Context, user_id string) (ok, editor bool) {
row := connPool.QueryRow(ctx, "SELECT editor FROM users WHERE id=$1", user_id)
err := row.Scan(&editor)
ok = (err == nil)
return
}