Skip to content

Commit 2b3c789

Browse files
committed
refactor: add email field to User type
Most backends don't need any change because they already populate this field.
1 parent a004f0d commit 2b3c789

5 files changed

Lines changed: 6 additions & 2 deletions

File tree

packages/decap-cms-backend-git-gateway/src/implementation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ export default class GitGateway implements Implementation {
381381
return {
382382
name: userData.name,
383383
login: userData.email,
384+
email: userData.email,
384385
avatar_url: userData.avatar_url,
385386
} as unknown as User;
386387
});

packages/decap-cms-backend-gitea/src/API.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export default class API {
131131

132132
static DEFAULT_COMMIT_MESSAGE = 'Automatically generated by Static CMS';
133133

134-
user(): Promise<{ full_name: string; login: string; avatar_url: string }> {
134+
user(): Promise<{ full_name: string; login: string; email: string; avatar_url: string }> {
135135
if (!this._userPromise) {
136136
this._userPromise = this.getUser();
137137
}

packages/decap-cms-backend-gitea/src/implementation.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export default class Gitea implements Implementation {
183183
return {
184184
name: user.full_name,
185185
login: user.login,
186+
email: user.email,
186187
avatar_url: user.avatar_url,
187188
token: state.token as string,
188189
};

packages/decap-cms-backend-github/src/API.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,14 @@ export default class API {
253253

254254
static DEFAULT_COMMIT_MESSAGE = 'Automatically generated by Decap CMS';
255255

256-
user(): Promise<{ name: string; login: string }> {
256+
user(): Promise<{ name: string; login: string; email?: string }> {
257257
if (!this._userPromise) {
258258
this._userPromise = this.getUser({ token: this.token });
259259
}
260260
return this._userPromise.then(user => ({
261261
name: user.name || 'Unknown',
262262
login: user.login,
263+
email: user.email ?? undefined,
263264
}));
264265
}
265266

packages/decap-cms-lib-util/src/implementation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export type Credentials = { token: string | {}; refresh_token?: string };
9090
export type User = Credentials & {
9191
backendName?: string;
9292
login?: string;
93+
email?: string;
9394
name: string;
9495
useOpenAuthoring?: boolean;
9596
};

0 commit comments

Comments
 (0)