init(api): add user authentication handler

also add error casting function to db.go
This commit is contained in:
2025-01-06 03:17:34 +03:00
parent 68d5063dd9
commit 18064db60a
2 changed files with 63 additions and 0 deletions
+9
View File
@@ -7,6 +7,7 @@ import (
"time"
"github.com/H1K0/SkazaNull/models"
"github.com/jackc/pgx/v5/pgconn"
"github.com/jackc/pgx/v5/pgxpool"
)
@@ -30,6 +31,14 @@ func InitDB(connString string) error {
return nil
}
func CastToPgError(err error) *pgconn.PgError {
pqErr, ok := err.(*pgconn.PgError)
if ok {
return pqErr
}
return nil
}
//#region User
func UserAuth(ctx context.Context, login string, password string) (user models.User, err error) {