feat: update callback handler and repository for user
All checks were successful
Backend ci / build (push) Successful in 3m23s

This commit is contained in:
d3m0k1d
2026-02-10 22:45:27 +03:00
parent a58e0f4451
commit 4a5c42ca06
6 changed files with 63 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ import (
"database/sql"
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/logger"
"gitea.d3m0k1d.ru/d3m0k1d/d3m0k1d.ru/backend/internal/storage"
)
type authRepository struct {
@@ -18,5 +19,23 @@ func NewAuthRepository(db *sql.DB) AuthRepository {
logger: logger.New(false),
}
}
func (a *authRepository) Test(ctx context.Context) {
func (a *authRepository) Register(ctx context.Context, user storage.UserReg) error {
_, err := a.db.Exec(
"INSERT INTO users(email, github_id, github_login, avatar_url) VALUES(?, ?, ?, ?)",
)
if err != nil {
a.logger.Error("error scan: " + err.Error())
return err
}
a.logger.Info("User registered:", "email", user.Email)
return nil
}
func (a *authRepository) IsRegistered(ctx context.Context, github_id int) (bool, error) {
row := a.db.QueryRow("SELECT id FROM users WHERE github_id = ?", github_id)
if row != nil {
return true, nil
}
return false, nil
}