···99 "log/slog"1010 "net/http"1111 "slices"1212+ "strings"1213 "time"13141415 comatproto "github.com/bluesky-social/indigo/api/atproto"···9291 go o.addToDefaultKnot(sessData.AccountDID.String())9392 go o.addToDefaultSpindle(sessData.AccountDID.String())9493 go o.ensureTangledProfile(sessData)9494+ go o.autoClaimTnglShDomain(sessData.AccountDID.String())95959696 if !o.Config.Core.Dev {9797 err = o.Posthog.Enqueue(posthog.Capture{···413411 }414412415413 return nil414414+}415415+416416+// autoClaimTnglShDomain checks if the user has a .tngl.sh handle and, if so,417417+// ensures their corresponding sites domain is claimed. This is idempotent —418418+// ClaimDomain is a no-op if the claim already exists.419419+func (o *OAuth) autoClaimTnglShDomain(did string) {420420+ l := o.Logger.With("did", did)421421+422422+ pdsDomain := strings.TrimPrefix(o.Config.Pds.Host, "https://")423423+ pdsDomain = strings.TrimPrefix(pdsDomain, "http://")424424+425425+ resolved, err := o.IdResolver.ResolveIdent(context.Background(), did)426426+ if err != nil {427427+ l.Error("autoClaimTnglShDomain: failed to resolve ident", "err", err)428428+ return429429+ }430430+431431+ handle := resolved.Handle.String()432432+ if !strings.HasSuffix(handle, "."+pdsDomain) {433433+ return434434+ }435435+436436+ if err := db.ClaimDomain(o.Db, did, handle); err != nil {437437+ l.Warn("autoClaimTnglShDomain: failed to claim domain", "domain", handle, "err", err)438438+ } else {439439+ l.Info("autoClaimTnglShDomain: claimed domain", "domain", handle)440440+ }416441}417442418443// getAppPasswordSession returns a cached AppPasswordSession, creating one if needed.
+18
appview/signup/signup.go
···311311 }312312 emailAdded = true313313314314+ // step 4: auto-claim <username>.<pds-domain> for this user.315315+ // All signups through this flow receive a <username>.tngl.sh handle316316+ // (or whatever the configured PDS host is), so we claim the matching317317+ // sites subdomain on their behalf. This is the only way to obtain a318318+ // *.tngl.sh sites domain; it cannot be claimed manually via settings.319319+ pdsDomain := strings.TrimPrefix(s.config.Pds.Host, "https://")320320+ pdsDomain = strings.TrimPrefix(pdsDomain, "http://")321321+ autoClaimDomain := username + "." + pdsDomain322322+ if err := db.ClaimDomain(s.db, did, autoClaimDomain); err != nil {323323+ s.l.Warn("failed to auto-claim sites domain at signup",324324+ "domain", autoClaimDomain,325325+ "did", did,326326+ "error", err,327327+ )328328+ } else {329329+ s.l.Info("auto-claimed sites domain at signup", "domain", autoClaimDomain, "did", did)330330+ }331331+314332 // if we get here, we've successfully created the account and added the email315333 success = true316334