From 626cfb61ac3940bee7a3acf1b1c5c4cae4ae410c Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 10 Apr 2019 15:04:27 +0900 Subject: テーブル分割 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/api/private/signin.ts | 10 ++++++---- src/server/api/private/signup.ts | 18 ++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/server/api/private') diff --git a/src/server/api/private/signin.ts b/src/server/api/private/signin.ts index c1fd908d8a..fe2e5577c2 100644 --- a/src/server/api/private/signin.ts +++ b/src/server/api/private/signin.ts @@ -4,7 +4,7 @@ import * as speakeasy from 'speakeasy'; import { publishMainStream } from '../../../services/stream'; import signin from '../common/signin'; import config from '../../../config'; -import { Users, Signins } from '../../../models'; +import { Users, Signins, UserProfiles } from '../../../models'; import { ILocalUser } from '../../../models/entities/user'; import { genId } from '../../../misc/gen-id'; @@ -45,13 +45,15 @@ export default async (ctx: Koa.BaseContext) => { return; } + const profile = await UserProfiles.findOne({ userId: user.id }); + // Compare password - const same = await bcrypt.compare(password, user.password); + const same = await bcrypt.compare(password, profile.password); if (same) { - if (user.twoFactorEnabled) { + if (profile.twoFactorEnabled) { const verified = (speakeasy as any).totp.verify({ - secret: user.twoFactorSecret, + secret: profile.twoFactorSecret, encoding: 'base32', token: token }); diff --git a/src/server/api/private/signup.ts b/src/server/api/private/signup.ts index 657e54decd..5ed25fa411 100644 --- a/src/server/api/private/signup.ts +++ b/src/server/api/private/signup.ts @@ -5,13 +5,13 @@ import generateUserToken from '../common/generate-native-user-token'; import config from '../../../config'; import fetchMeta from '../../../misc/fetch-meta'; import * as recaptcha from 'recaptcha-promise'; -import { Users, RegistrationTickets, UserServiceLinkings, UserKeypairs } from '../../../models'; +import { Users, RegistrationTickets, UserProfiles, UserKeypairs } from '../../../models'; 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'; import { toPuny } from '../../../misc/convert-host'; +import { UserProfile } from '../../../models/entities/user-profile'; export default async (ctx: Koa.BaseContext) => { const body = ctx.request.body as any; @@ -106,23 +106,21 @@ export default async (ctx: Koa.BaseContext) => { usernameLower: username.toLowerCase(), host: toPuny(host), token: secret, - password: hash, isAdmin: config.autoAdmin && usersCount === 0, - autoAcceptFollowed: true, - autoWatch: false } as User); await UserKeypairs.save({ - id: genId(), publicKey: keyPair[0], privateKey: keyPair[1], userId: account.id } as UserKeypair); - await UserServiceLinkings.save({ - id: genId(), - userId: account.id - } as UserServiceLinking); + await UserProfiles.save({ + userId: account.id, + autoAcceptFollowed: true, + autoWatch: false, + password: hash, + } as Partial); usersChart.update(account, true); -- cgit v1.2.3-freya