From e8bde94e5bccf1303a1aec2f86544d59452bbb9d Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 2 Apr 2018 04:01:34 +0900 Subject: Refactor --- src/server/api/bot/core.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/server/api/bot/core.ts') diff --git a/src/server/api/bot/core.ts b/src/server/api/bot/core.ts index f84f1f5dca..d636cc26e7 100644 --- a/src/server/api/bot/core.ts +++ b/src/server/api/bot/core.ts @@ -1,7 +1,7 @@ import * as EventEmitter from 'events'; import * as bcrypt from 'bcryptjs'; -import User, { ILocalAccount, IUser, init as initUser } from '../../../models/user'; +import User, { IUser, init as initUser, ILocalUser } from '../../../models/user'; import getPostSummary from '../../../common/get-post-summary'; import getUserSummary from '../../../common/user/get-summary'; @@ -198,7 +198,7 @@ abstract class Context extends EventEmitter { } class SigninContext extends Context { - private temporaryUser: IUser = null; + private temporaryUser: ILocalUser = null; public async greet(): Promise { return 'まずユーザー名を教えてください:'; @@ -207,14 +207,14 @@ class SigninContext extends Context { public async q(query: string): Promise { if (this.temporaryUser == null) { // Fetch user - const user: IUser = await User.findOne({ + const user = await User.findOne({ usernameLower: query.toLowerCase(), host: null }, { fields: { data: false } - }); + }) as ILocalUser; if (user === null) { return `${query}というユーザーは存在しませんでした... もう一度教えてください:`; @@ -225,7 +225,7 @@ class SigninContext extends Context { } } else { // Compare password - const same = await bcrypt.compare(query, (this.temporaryUser.account as ILocalAccount).password); + const same = await bcrypt.compare(query, this.temporaryUser.account.password); if (same) { this.bot.signin(this.temporaryUser); -- cgit v1.2.3-freya