refactor(db): move users and persons functions into separate files
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user