feat: expand companion platform, device controls, and memoir workflows
ci / verify (push) Canceled after 0s
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:
@@ -0,0 +1,58 @@
|
||||
package onboarding
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Each view is a request-local value. Pools and immutable configuration are
|
||||
// shared; customer and operator credentials, sessions and cookies are separate.
|
||||
func (s *Service) operatorView() *Service {
|
||||
view := *s
|
||||
view.operatorLogin = true
|
||||
return &view
|
||||
}
|
||||
func (s *Service) loginSessionTable() string {
|
||||
if s.operatorLogin {
|
||||
return "operator_login_session"
|
||||
}
|
||||
return "customer_login_session"
|
||||
}
|
||||
func (s *Service) loginSMSTable() string {
|
||||
if s.operatorLogin {
|
||||
return "operator_sms_challenge"
|
||||
}
|
||||
return "customer_sms_challenge"
|
||||
}
|
||||
func (s *Service) phoneCredentialTable() string {
|
||||
if s.operatorLogin {
|
||||
return "operator_phone_credential"
|
||||
}
|
||||
return "customer_phone_credential"
|
||||
}
|
||||
func (s *Service) accountSessionTable() string {
|
||||
if s.operatorLogin {
|
||||
return "operator_account_session"
|
||||
}
|
||||
return "onboarding_account_session"
|
||||
}
|
||||
func (s *Service) accountPredicate() string {
|
||||
if s.operatorLogin {
|
||||
return "ua.account_kind='operator' AND ua.platform_role IN ('ops_admin','ops_operator','ops_approver','ops_viewer')"
|
||||
}
|
||||
return "ua.account_kind='customer' AND ua.platform_role='customer'"
|
||||
}
|
||||
func (s *Service) logoutKinds() []bool {
|
||||
if s.operatorLogin {
|
||||
return []bool{true}
|
||||
}
|
||||
return []bool{true, false}
|
||||
}
|
||||
|
||||
func (s *Service) OperatorAuth(next http.Handler) http.Handler {
|
||||
return s.operatorView().CustomerAuth(next)
|
||||
}
|
||||
|
||||
func (s *Service) ProvisionOperatorPhone(ctx context.Context, userID, issuer, subject, phone, password, requestID string) (bool, error) {
|
||||
return s.operatorView().provisionPhone(ctx, userID, issuer, subject, phone, password, requestID)
|
||||
}
|
||||
Reference in New Issue
Block a user