handleExportUserData returns a complete dump of the authenticated user's data as JSON. Used for the right-of-access flow (GDPR Art. 15, CCPA equivalent). Output is deterministic-ordered (created_at) so a caller diffing exports across time gets stable results. ExportUserDataCore assembles the full u
(ctx context.Context, userID string)
| 24 | // ExportUserDataCore assembles the full user-data export (store export + |
| 25 | // OAuth connections). HTTP-free; serves GET /v1/account/export. |
| 26 | func (a *API) ExportUserDataCore(ctx context.Context, userID string) (*identity.UserExport, error) { |
| 27 | dump, err := a.store.ExportUserData(ctx, userID) |
| 28 | if err != nil { |
| 29 | return nil, err |
| 30 | } |
| 31 | // Append OAuth connections, if OAuth is wired. Side-call so the identity |
| 32 | // package needs no oauth dependency; failure is logged, not fatal. |
| 33 | if a.oauthStorage != nil { |
| 34 | conns, err := a.oauthStorage.ExportConnectionsForUser(ctx, userID) |
| 35 | if err != nil { |
| 36 | log.Printf("[api] export oauth connections failed: user=%s err=%v", userID, err) |
| 37 | } else { |
| 38 | dump.OAuthConnections = make([]identity.OAuthConnectionEntry, len(conns)) |
| 39 | for i, c := range conns { |
| 40 | dump.OAuthConnections[i] = identity.OAuthConnectionEntry{ |
| 41 | ClientID: c.ClientID, |
| 42 | ClientName: c.ClientName, |
| 43 | AgentEmail: c.AgentEmail, |
| 44 | Scope: c.Scope, |
| 45 | IssuedAt: c.IssuedAt, |
| 46 | ExpiresAt: c.ExpiresAt, |
| 47 | RevokedAt: c.RevokedAt, |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | return dump, nil |
| 53 | } |
| 54 | |
| 55 | // handleDeleteUserData wipes the authenticated user and every record |
| 56 | // tied to them, in a single Postgres transaction. Used for the |
nothing calls this directly
no test coverage detected