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
34 lines
593 B
Go
34 lines
593 B
Go
package auth
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/zap-proto/zip"
|
|
|
|
"github.com/hanzoai/commerce/auth/password"
|
|
"github.com/hanzoai/commerce/util/form"
|
|
)
|
|
|
|
type LoginForm struct {
|
|
Email string
|
|
Password string
|
|
}
|
|
|
|
func (f LoginForm) PasswordHashAndCompare(hash []byte) bool {
|
|
return password.HashAndCompare(hash, f.Password)
|
|
}
|
|
|
|
func (f LoginForm) PasswordHash() ([]byte, error) {
|
|
return password.Hash(f.Password)
|
|
}
|
|
|
|
func (f *LoginForm) Parse(c *zip.Ctx) error {
|
|
if err := form.Parse(c, f); err != nil {
|
|
return err
|
|
}
|
|
|
|
f.Email = strings.TrimSpace(strings.ToLower(f.Email))
|
|
|
|
return nil
|
|
}
|