add auth to backend and frontend

This commit is contained in:
2026-02-24 10:42:36 -05:00
parent 11eb192e2a
commit 0d5cc4d21f
14 changed files with 336 additions and 35 deletions
+14
View File
@@ -16,6 +16,20 @@ func NewUserService(db *sql.DB) *UserService {
return &UserService{db: db}
}
func (s *UserService) GetUserByID(id int) (*models.User, error) {
var user models.User
err := s.db.QueryRow(
`SELECT id, email, created_at FROM users WHERE id = $1`, id,
).Scan(&user.ID, &user.Email, &user.CreatedAt)
if err != nil {
return nil, err
}
return &user, nil
}
func (s *UserService) CreateUser(email string, password string) (*models.User, error) {
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)