summaryrefslogtreecommitdiff
path: root/src/server/api/bot/core.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-02 04:01:34 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-02 04:01:34 +0900
commite8bde94e5bccf1303a1aec2f86544d59452bbb9d (patch)
tree50fb517ca91c3ba5e10b2186046880a29137877d /src/server/api/bot/core.ts
parentFix: Add missing bracket (diff)
downloadsharkey-e8bde94e5bccf1303a1aec2f86544d59452bbb9d.tar.gz
sharkey-e8bde94e5bccf1303a1aec2f86544d59452bbb9d.tar.bz2
sharkey-e8bde94e5bccf1303a1aec2f86544d59452bbb9d.zip
Refactor
Diffstat (limited to 'src/server/api/bot/core.ts')
-rw-r--r--src/server/api/bot/core.ts10
1 files changed, 5 insertions, 5 deletions
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<string> {
return 'まずユーザー名を教えてください:';
@@ -207,14 +207,14 @@ class SigninContext extends Context {
public async q(query: string): Promise<string> {
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);