diff options
Diffstat (limited to 'server/helpers/custom-validators/accounts.ts')
-rw-r--r-- | server/helpers/custom-validators/accounts.ts | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/server/helpers/custom-validators/accounts.ts b/server/helpers/custom-validators/accounts.ts index e3c477414..8dc5d1f0d 100644 --- a/server/helpers/custom-validators/accounts.ts +++ b/server/helpers/custom-validators/accounts.ts | |||
@@ -2,8 +2,7 @@ import * as Bluebird from 'bluebird' | |||
2 | import { Response } from 'express' | 2 | import { Response } from 'express' |
3 | import 'express-validator' | 3 | import 'express-validator' |
4 | import * as validator from 'validator' | 4 | import * as validator from 'validator' |
5 | import { database as db } from '../../initializers' | 5 | import { AccountModel } from '../../models/account/account' |
6 | import { AccountInstance } from '../../models' | ||
7 | import { isUserUsernameValid } from './users' | 6 | import { isUserUsernameValid } from './users' |
8 | 7 | ||
9 | function isAccountNameValid (value: string) { | 8 | function isAccountNameValid (value: string) { |
@@ -11,24 +10,24 @@ function isAccountNameValid (value: string) { | |||
11 | } | 10 | } |
12 | 11 | ||
13 | function isAccountIdExist (id: number | string, res: Response) { | 12 | function isAccountIdExist (id: number | string, res: Response) { |
14 | let promise: Bluebird<AccountInstance> | 13 | let promise: Bluebird<AccountModel> |
15 | 14 | ||
16 | if (validator.isInt('' + id)) { | 15 | if (validator.isInt('' + id)) { |
17 | promise = db.Account.load(+id) | 16 | promise = AccountModel.load(+id) |
18 | } else { // UUID | 17 | } else { // UUID |
19 | promise = db.Account.loadByUUID('' + id) | 18 | promise = AccountModel.loadByUUID('' + id) |
20 | } | 19 | } |
21 | 20 | ||
22 | return isAccountExist(promise, res) | 21 | return isAccountExist(promise, res) |
23 | } | 22 | } |
24 | 23 | ||
25 | function isLocalAccountNameExist (name: string, res: Response) { | 24 | function isLocalAccountNameExist (name: string, res: Response) { |
26 | const promise = db.Account.loadLocalByName(name) | 25 | const promise = AccountModel.loadLocalByName(name) |
27 | 26 | ||
28 | return isAccountExist(promise, res) | 27 | return isAccountExist(promise, res) |
29 | } | 28 | } |
30 | 29 | ||
31 | async function isAccountExist (p: Bluebird<AccountInstance>, res: Response) { | 30 | async function isAccountExist (p: Bluebird<AccountModel>, res: Response) { |
32 | const account = await p | 31 | const account = await p |
33 | 32 | ||
34 | if (!account) { | 33 | if (!account) { |