mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-07 06:08:06 +02:00
feat: add support for multiple emails
This commit is contained in:
+8
-3
@@ -64,19 +64,24 @@ async function connect(db) {
|
|||||||
}).save()
|
}).save()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const user = await new UserModel({
|
const user = new UserModel({
|
||||||
accessTokens: {
|
accessTokens: {
|
||||||
github: r.accessToken,
|
github: r.accessToken,
|
||||||
},
|
},
|
||||||
username: r.username,
|
username: r.username,
|
||||||
email: r.profile.emails[0]?.value,
|
emails: r.profile.emails.map((email) => {
|
||||||
|
return { email: email.value, default: false };
|
||||||
|
}),
|
||||||
photo: r.profile.photos[0]?.value,
|
photo: r.profile.photos[0]?.value,
|
||||||
repositories: (await Promise.all(repositoryModels)).map((d) => d._id),
|
repositories: (await Promise.all(repositoryModels)).map((d) => d._id),
|
||||||
default: {
|
default: {
|
||||||
terms: r.default.terms,
|
terms: r.default.terms,
|
||||||
options: r.default.options,
|
options: r.default.options,
|
||||||
},
|
},
|
||||||
}).save();
|
});
|
||||||
|
if (user.emails.length) user.emails[0].default = true;
|
||||||
|
|
||||||
|
await user.save();
|
||||||
|
|
||||||
localResolve(user);
|
localResolve(user);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,12 @@ const UserSchema = new Schema({
|
|||||||
type: String,
|
type: String,
|
||||||
index: { unique: true },
|
index: { unique: true },
|
||||||
},
|
},
|
||||||
email: String,
|
emails: [
|
||||||
|
{
|
||||||
|
email: { type: String },
|
||||||
|
default: Boolean,
|
||||||
|
},
|
||||||
|
],
|
||||||
photo: String,
|
photo: String,
|
||||||
repositories: [String],
|
repositories: [String],
|
||||||
default: {
|
default: {
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ export interface IUser {
|
|||||||
};
|
};
|
||||||
|
|
||||||
username: string;
|
username: string;
|
||||||
email: string;
|
emails: {
|
||||||
|
email: string;
|
||||||
|
default: boolean;
|
||||||
|
}[];
|
||||||
photo?: string;
|
photo?: string;
|
||||||
|
|
||||||
repositories?: number[];
|
repositories?: number[];
|
||||||
|
|||||||
Reference in New Issue
Block a user