feat: update auth and fix url for gitea
This commit is contained in:
@@ -20,16 +20,20 @@ func NewAuthRepository(db *sql.DB) AuthRepository {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *authRepository) Register(ctx context.Context, user storage.UserReg) error {
|
||||
func (a *authRepository) Register(ctx context.Context, user storage.UserReg) (int, error) {
|
||||
var id int
|
||||
_, 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.Error("error request: " + err.Error())
|
||||
return 0, err
|
||||
}
|
||||
row := a.db.QueryRow("SELECT id FROM users WHERE github_id = ?", user.GithubID)
|
||||
row.Scan(&id)
|
||||
|
||||
a.logger.Info("User registered:", "email", user.Email)
|
||||
return nil
|
||||
return id, nil
|
||||
}
|
||||
|
||||
func (a *authRepository) IsRegistered(ctx context.Context, github_id int) (bool, error) {
|
||||
|
||||
Reference in New Issue
Block a user