From 27ca691543acfeb89e3e1c7de257cfa3213c8f68 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Tue, 27 Mar 2018 12:02:43 +0900 Subject: [PATCH 1/2] Add host field to User --- src/api/models/user.ts | 1 + src/api/private/signup.ts | 1 + tools/migration/shell.1522116709.user-host.js | 1 + 3 files changed, 3 insertions(+) create mode 100644 tools/migration/shell.1522116709.user-host.js diff --git a/src/api/models/user.ts b/src/api/models/user.ts index 042f13b23..7c4b993e9 100644 --- a/src/api/models/user.ts +++ b/src/api/models/user.ts @@ -58,6 +58,7 @@ export type IUser = { pinned_post_id: mongo.ObjectID; is_suspended: boolean; keywords: string[]; + host: string; account: { keypair: string; email: string; diff --git a/src/api/private/signup.ts b/src/api/private/signup.ts index 690f3001c..a4c06b5f5 100644 --- a/src/api/private/signup.ts +++ b/src/api/private/signup.ts @@ -119,6 +119,7 @@ export default async (req: express.Request, res: express.Response) => { drive_capacity: 1073741824, // 1GB username: username, username_lower: username.toLowerCase(), + host: null, account: { keypair: generateKeypair(), token: secret, diff --git a/tools/migration/shell.1522116709.user-host.js b/tools/migration/shell.1522116709.user-host.js new file mode 100644 index 000000000..b354709a6 --- /dev/null +++ b/tools/migration/shell.1522116709.user-host.js @@ -0,0 +1 @@ +db.users.update({ }, { $set: { host: null } }, { multi: true }); From 3eb659b649535efb42e9401a7bfaff7526f84327 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Tue, 27 Mar 2018 12:18:22 +0900 Subject: [PATCH 2/2] Fix keypair assignment in a migration script --- tools/migration/node.1522066477.user-account-keypair.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/migration/node.1522066477.user-account-keypair.js b/tools/migration/node.1522066477.user-account-keypair.js index 4a968aae2..effea137c 100644 --- a/tools/migration/node.1522066477.user-account-keypair.js +++ b/tools/migration/node.1522066477.user-account-keypair.js @@ -6,9 +6,7 @@ const updates = []; User.find({}).each(function(user) { updates.push(User.update({ _id: user._id }, { $set: { - account: { - keypair: generate(), - } + 'account.keypair': generate(), } })); }).then(function () {