feat: expand companion platform, device controls, and memoir workflows
ci / verify (push) Canceled after 0s

Add customer and operator login, BLE provisioning, device fleet controls, call memory, memoir generation, and refreshed family and maintenance portals. Include API contracts, migrations, firmware sources, tests, assets, and deployment documentation.
This commit is contained in:
Codex Local
2026-10-08 10:06:44 +08:00
parent 98fb2965d0
commit bf1233d5df
861 changed files with 94614 additions and 3209 deletions
+45
View File
@@ -0,0 +1,45 @@
package identity
import (
"context"
"errors"
"strings"
"unicode"
"unicode/utf8"
)
var ErrInvalidDisplayName = errors.New("invalid display name")
func ValidateDisplayName(name string) (string, error) {
name = strings.TrimSpace(name)
if !utf8.ValidString(name) || utf8.RuneCountInString(name) < 1 || utf8.RuneCountInString(name) > 80 {
return "", ErrInvalidDisplayName
}
for _, r := range name {
if unicode.IsControl(r) {
return "", ErrInvalidDisplayName
}
}
return name, nil
}
// The principal comes from authenticated middleware. Callers cannot select another account.
func (r *Repository) UpdateDisplayName(ctx context.Context, principal Principal, name string) error {
name, err := ValidateDisplayName(name)
if err != nil {
return err
}
if principal.Issuer == "" || principal.Subject == "" {
return ErrAccessDenied
}
result, err := r.pool.Exec(ctx, `UPDATE user_account ua SET display_name=$3, updated_at=now()
FROM tenant t WHERE ua.tenant_id=t.id AND t.status='active' AND ua.status='active'
AND ua.oidc_issuer=$1 AND ua.oidc_subject=$2`, principal.Issuer, principal.Subject, name)
if err != nil {
return err
}
if result.RowsAffected() == 0 {
return ErrAccountNotFound
}
return nil
}