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