mirror of
https://github.com/marcusDenslow/terminalShop.git
synced 2026-10-25 18:08:45 +01:00
Compare commits
1 Commits
stale-erro
...
bugssssss
| Author | SHA1 | Date | |
|---|---|---|---|
| edc032d6d4 |
@@ -31,7 +31,7 @@ var (
|
||||
)
|
||||
|
||||
func storeRedirect(stripeURL string) string {
|
||||
b := make([]byte, 4)
|
||||
b := make([]byte, 16)
|
||||
rand.Read(b)
|
||||
token := hex.EncodeToString(b)
|
||||
payRedirectsMu.Lock()
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"strconv"
|
||||
|
||||
"github.com/go-chi/httprate"
|
||||
"terminalShop/pkg/utils"
|
||||
)
|
||||
@@ -29,7 +31,7 @@ func RateLimitByUser(limit int, window time.Duration) func(http.Handler) http.Ha
|
||||
// Fall back to IP if no user context (shouldn't happen on protected routes).
|
||||
return httprate.KeyByIP(r)
|
||||
}
|
||||
return http.CanonicalHeaderKey("user") + ":" + string(rune(userID)), nil
|
||||
return "user:" + strconv.FormatUint(uint64(userID), 10), nil
|
||||
}),
|
||||
httprate.WithLimitHandler(func(w http.ResponseWriter, r *http.Request) {
|
||||
utils.RespondError(w, http.StatusTooManyRequests, "RATE_LIMITED", "too many requests", nil)
|
||||
|
||||
@@ -594,7 +594,7 @@ func (c *Client) CollectCard() (string, error) {
|
||||
|
||||
var collectResp CollectCardResponse
|
||||
if err := json.NewDecoder(resp.Body).Decode(&collectResp); err != nil {
|
||||
return "", fmt.Errorf("failed to devode collect response: %w", err)
|
||||
return "", fmt.Errorf("failed to decode collect response: %w", err)
|
||||
}
|
||||
|
||||
if !collectResp.Success {
|
||||
|
||||
@@ -29,7 +29,7 @@ const (
|
||||
large // viewportWidth >= 80
|
||||
)
|
||||
|
||||
// page represetnts the currently active TUI screen
|
||||
// page represents the currently active TUI screen
|
||||
type page int
|
||||
|
||||
const (
|
||||
@@ -62,7 +62,7 @@ type Model struct {
|
||||
StripePublicKey string
|
||||
|
||||
// One-shop auth command - capture pubKeyStr in closure, not stored on Model
|
||||
autchCmd tea.Cmd
|
||||
authCmd tea.Cmd
|
||||
|
||||
// Shared data
|
||||
Username string
|
||||
@@ -342,7 +342,7 @@ func (m Model) fetchProductsCmd() tea.Msg {
|
||||
|
||||
func (m Model) Init() tea.Cmd {
|
||||
return tea.Batch(
|
||||
m.autchCmd,
|
||||
m.authCmd,
|
||||
tea.Tick(1500*time.Millisecond, func(t time.Time) tea.Msg {
|
||||
return DelayCompleteMsg{}
|
||||
}),
|
||||
@@ -845,7 +845,7 @@ func NewModelWithAuth(renderer *lipgloss.Renderer, fingerprint string, pubKeyStr
|
||||
m.APIClient = api.NewClient("http://localhost:8000", "")
|
||||
}
|
||||
|
||||
m.autchCmd = func() tea.Msg {
|
||||
m.authCmd = func() tea.Msg {
|
||||
token, user, err := m.APIClient.GetOrCreateToken(
|
||||
fingerprint,
|
||||
pubKeyStr,
|
||||
|
||||
@@ -42,7 +42,7 @@ func (m Model) SplashView() string {
|
||||
cursor = " "
|
||||
}
|
||||
|
||||
logo := accent.Render("terminal coffe") + cursor
|
||||
logo := accent.Render("terminal coffee") + cursor
|
||||
|
||||
content := lipgloss.JoinVertical(
|
||||
lipgloss.Center,
|
||||
|
||||
@@ -129,11 +129,11 @@ func (m Model) View() string {
|
||||
child = lipgloss.JoinVertical(lipgloss.Left, header, content, footer)
|
||||
}
|
||||
} else if breadcrumbs != "" {
|
||||
ccontentWithPadding := lipgloss.NewStyle().MarginTop(marginTop).MarginBottom(marginBottom).Height(availableContentHeight).Render(content)
|
||||
child = lipgloss.JoinVertical(lipgloss.Left, header, breadcrumbs, ccontentWithPadding, footer)
|
||||
contentWithPadding := lipgloss.NewStyle().MarginTop(marginTop).MarginBottom(marginBottom).Height(availableContentHeight).Render(content)
|
||||
child = lipgloss.JoinVertical(lipgloss.Left, header, breadcrumbs, contentWithPadding, footer)
|
||||
} else {
|
||||
ccontentWithPadding := lipgloss.NewStyle().MarginTop(marginTop).MarginBottom(marginBottom).Height(availableContentHeight).Render(content)
|
||||
child = lipgloss.JoinVertical(lipgloss.Left, header, ccontentWithPadding, footer)
|
||||
contentWithPadding := lipgloss.NewStyle().MarginTop(marginTop).MarginBottom(marginBottom).Height(availableContentHeight).Render(content)
|
||||
child = lipgloss.JoinVertical(lipgloss.Left, header, contentWithPadding, footer)
|
||||
}
|
||||
|
||||
// Constrain the assembled layout to the container dimensions
|
||||
|
||||
Reference in New Issue
Block a user