Skip to content

Commit 3604c59

Browse files
authored
Merge pull request #45 from datocms/c14/security/secure-change-email-flow
Generate new schema
2 parents b86e18a + e9a760b commit 3604c59

4 files changed

Lines changed: 108 additions & 0 deletions

File tree

packages/dashboard-client/resources.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,27 @@
225225
"responseType": "AccountConvertToOrganizationJobSchema",
226226
"name": "convertToOrganization",
227227
"rawName": "rawConvertToOrganization"
228+
},
229+
{
230+
"returnsItem": false,
231+
"requestBodyRequiresItem": false,
232+
"offersNestedItemsOptionInQueryParams": false,
233+
"rel": "confirm_email_change",
234+
"urlTemplate": "/account/confirm-email-change",
235+
"method": "POST",
236+
"comment": "Confirm email change",
237+
"urlPlaceholders": [],
238+
"requestBodyType": "AccountConfirmEmailChangeSchema",
239+
"optionalRequestBody": false,
240+
"requestStructure": {
241+
"type": "account",
242+
"attributes": ["token"],
243+
"relationships": []
244+
},
245+
"queryParamsRequired": false,
246+
"responseType": "AccountConfirmEmailChangeTargetSchema",
247+
"name": "confirmEmailChange",
248+
"rawName": "rawConfirmEmailChange"
228249
}
229250
],
230251
"namespace": "account",

packages/dashboard-client/src/generated/ApiTypes.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,13 +946,18 @@ export type Account = {
946946
* Whether 2-factor authentication is active for this account or not
947947
*/
948948
is_2fa_active: boolean;
949+
/**
950+
* Pending email address awaiting confirmation (only present if confirmation token hasn't expired)
951+
*/
952+
pending_email?: string | null;
949953
active_subscription: null | PerOwnerPricingSubscriptionData;
950954
billing_profile: null | PerOwnerPricingBillingProfileData;
951955
default_organization: null | OrganizationData;
952956
};
953957
export type AccountDestroyJobSchema = Account;
954958
export type AccountSelfTargetSchema = Account;
955959
export type AccountDeactivate_2FaTargetSchema = Account;
960+
export type AccountConfirmEmailChangeTargetSchema = Account;
956961
/**
957962
* JSON API data
958963
*
@@ -1014,6 +1019,10 @@ export type AccountAttributes = {
10141019
* Whether 2-factor authentication is active for this account or not
10151020
*/
10161021
is_2fa_active: boolean;
1022+
/**
1023+
* Pending email address awaiting confirmation (only present if confirmation token hasn't expired)
1024+
*/
1025+
pending_email?: string | null;
10171026
};
10181027
/**
10191028
* JSON API links
@@ -1347,6 +1356,17 @@ export type OrganizationDestroySchema = {
13471356
*/
13481357
password: string;
13491358
};
1359+
/**
1360+
* This interface was referenced by `Account`'s JSON-Schema
1361+
* via the `confirm_email_change.schema` link.
1362+
*/
1363+
export type AccountConfirmEmailChangeSchema = {
1364+
type?: AccountType;
1365+
/**
1366+
* Email confirmation token
1367+
*/
1368+
token: string;
1369+
};
13501370
/**
13511371
* A project represents a specific DatoCMS administrative area
13521372
*

packages/dashboard-client/src/generated/RawApiTypes.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,10 @@ export type AccountAttributes = {
811811
* Whether 2-factor authentication is active for this account or not
812812
*/
813813
is_2fa_active: boolean;
814+
/**
815+
* Pending email address awaiting confirmation (only present if confirmation token hasn't expired)
816+
*/
817+
pending_email?: string | null;
814818
};
815819
/**
816820
* JSON API links
@@ -2182,6 +2186,28 @@ export type OrganizationDestroyTargetSchema = {
21822186
export type OrganizationDestroyJobSchema = {
21832187
data: Organization;
21842188
};
2189+
/**
2190+
* This interface was referenced by `Account`'s JSON-Schema
2191+
* via the `confirm_email_change.schema` link.
2192+
*/
2193+
export type AccountConfirmEmailChangeSchema = {
2194+
data: {
2195+
type: AccountType;
2196+
attributes: {
2197+
/**
2198+
* Email confirmation token
2199+
*/
2200+
token: string;
2201+
};
2202+
};
2203+
};
2204+
/**
2205+
* This interface was referenced by `Account`'s JSON-Schema
2206+
* via the `confirm_email_change.targetSchema` link.
2207+
*/
2208+
export type AccountConfirmEmailChangeTargetSchema = {
2209+
data: Account;
2210+
};
21852211
/**
21862212
* A per-project subscription record
21872213
*

packages/dashboard-client/src/generated/resources/Account.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,4 +329,45 @@ export default class Account extends BaseResource {
329329
},
330330
);
331331
}
332+
333+
/**
334+
* Confirm email change
335+
*
336+
* @throws {ApiError}
337+
* @throws {TimeoutError}
338+
*/
339+
confirmEmailChange(body: ApiTypes.AccountConfirmEmailChangeSchema) {
340+
return this.rawConfirmEmailChange(
341+
Utils.serializeRequestBody<RawApiTypes.AccountConfirmEmailChangeSchema>(
342+
body,
343+
{
344+
type: 'account',
345+
attributes: ['token'],
346+
relationships: [],
347+
},
348+
),
349+
).then((body) =>
350+
Utils.deserializeResponseBody<ApiTypes.AccountConfirmEmailChangeTargetSchema>(
351+
body,
352+
),
353+
);
354+
}
355+
356+
/**
357+
* Confirm email change
358+
*
359+
* @throws {ApiError}
360+
* @throws {TimeoutError}
361+
*/
362+
rawConfirmEmailChange(
363+
body: RawApiTypes.AccountConfirmEmailChangeSchema,
364+
): Promise<RawApiTypes.AccountConfirmEmailChangeTargetSchema> {
365+
return this.client.request<RawApiTypes.AccountConfirmEmailChangeTargetSchema>(
366+
{
367+
method: 'POST',
368+
url: '/account/confirm-email-change',
369+
body,
370+
},
371+
);
372+
}
332373
}

0 commit comments

Comments
 (0)