mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
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
26 lines
732 B
Go
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})
|
|
}
|