Phase 10, part 3: signing in and out, resets, locks and two-factor
The server edition now starts. Sign-in by email and password, limited per address and per IP; ten failures in a row lock the account and email its owner, and a reset by email (or an admin) unlocks it. Settings → Your account has the profile, the password, where you're signed in, and two-factor sign-in with an authenticator app (TOTP, from a QR code) and ten recovery codes. The app's own mail goes through SUPERMARKET_MAIL_URL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,7 @@ import (
|
||||
"time"
|
||||
|
||||
"supermarket/internal/ai"
|
||||
"supermarket/internal/appmail"
|
||||
"supermarket/internal/backup"
|
||||
"supermarket/internal/config"
|
||||
"supermarket/internal/content"
|
||||
@@ -320,6 +321,7 @@ func run(log *slog.Logger) error {
|
||||
MCPToken: token,
|
||||
MCPSocket: filepath.Join(hostData, filepath.Base(mcpSocket)),
|
||||
MCP: mcpserver.Handler(database, token, version),
|
||||
Mail: appMail(cfg),
|
||||
Log: log,
|
||||
ImportStatus: status,
|
||||
ImportErr: importErr,
|
||||
@@ -364,6 +366,7 @@ func run(log *slog.Logger) error {
|
||||
go srv.RunSEO(ctx)
|
||||
go srv.RunMetrics(ctx)
|
||||
go srv.RunBackups(ctx)
|
||||
go srv.RunAccounts(ctx)
|
||||
// A sync falls due, and a claim times out, without anything being
|
||||
// written: refresh the state file each minute.
|
||||
go func() {
|
||||
@@ -401,6 +404,14 @@ func run(log *slog.Logger) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// appMail sends the app's own mail, where there's a mail server.
|
||||
func appMail(cfg *config.Config) appmail.Sender {
|
||||
if cfg.Mail == nil {
|
||||
return nil
|
||||
}
|
||||
return &appmail.SMTP{Conf: cfg.Mail}
|
||||
}
|
||||
|
||||
// setupLink makes a new one-time link to create the owner, or returns ""
|
||||
// if there's an owner already.
|
||||
func setupLink(d *db.DB, publicURL string) (string, error) {
|
||||
|
||||
Reference in New Issue
Block a user