Files
zeekay 1943f1c093 Hanzo Commerce
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans,
usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0.

Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
2026-09-23 21:52:16 -07:00

26 lines
732 B
Go

package account
import (
"github.com/zap-proto/zip"
"github.com/hanzoai/commerce/datastore"
"github.com/hanzoai/commerce/middleware"
"github.com/hanzoai/commerce/models/user"
"github.com/hanzoai/commerce/util/json/http"
)
func exists(c *zip.Ctx) error {
org := middleware.GetOrganization(c)
db := datastore.New(org.Namespaced(c.Context()))
emailorusername := c.Param("emailorusername")
usr := user.New(db)
if err := usr.GetByEmail(emailorusername); err == nil {
return http.Render(c, 200, map[string]any{"exists": true})
} else if err := usr.GetByUsername(emailorusername); err == nil {
return http.Render(c, 200, map[string]any{"exists": true})
}
return http.Render(c, 200, map[string]any{"exists": false})
}