diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-04-08 03:35:02 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-04-08 03:35:02 +0900 |
| commit | 142d59be85cd06b11d9df1375bcd0a84c0425e22 (patch) | |
| tree | 63255a389c37ab19c9b9fb80d9c633275340a155 /src/server/api/private/signup.ts | |
| parent | Fix bug (diff) | |
| download | sharkey-142d59be85cd06b11d9df1375bcd0a84c0425e22.tar.gz sharkey-142d59be85cd06b11d9df1375bcd0a84c0425e22.tar.bz2 sharkey-142d59be85cd06b11d9df1375bcd0a84c0425e22.zip | |
Fix bug
Diffstat (limited to 'src/server/api/private/signup.ts')
| -rw-r--r-- | src/server/api/private/signup.ts | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/server/api/private/signup.ts b/src/server/api/private/signup.ts index 1d304b8e11..8ab702bd8a 100644 --- a/src/server/api/private/signup.ts +++ b/src/server/api/private/signup.ts @@ -10,6 +10,7 @@ import { genId } from '../../../misc/gen-id'; import { usersChart } from '../../../services/chart'; import { UserServiceLinking } from '../../../models/entities/user-service-linking'; import { User } from '../../../models/entities/user'; +import { UserKeypair } from '../../../models/entities/user-keypair'; export default async (ctx: Koa.BaseContext) => { const body = ctx.request.body as any; @@ -80,6 +81,23 @@ export default async (ctx: Koa.BaseContext) => { return; } + const keyPair = await new Promise<string[]>((s, j) => + generateKeyPair('rsa', { + modulusLength: 4096, + publicKeyEncoding: { + type: 'pkcs1', + format: 'pem' + }, + privateKeyEncoding: { + type: 'pkcs1', + format: 'pem', + cipher: undefined, + passphrase: undefined + } + }, (e, publicKey, privateKey) => + e ? j(e) : s([publicKey, privateKey]) + )); + const account = await Users.save({ id: genId(), createdAt: new Date(), @@ -95,21 +113,10 @@ export default async (ctx: Koa.BaseContext) => { await UserKeypairs.save({ id: genId(), - keyPem: await new Promise<string>((s, j) => generateKeyPair('rsa', { - modulusLength: 4096, - publicKeyEncoding: { - type: 'pkcs1', - format: 'pem' - }, - privateKeyEncoding: { - type: 'pkcs1', - format: 'pem', - cipher: undefined, - passphrase: undefined - } - }, (e, _, x) => e ? j(e) : s(x))), + publicKey: keyPair[0], + privateKey: keyPair[1], userId: account.id - }); + } as UserKeypair); await UserServiceLinkings.save({ id: genId(), |