aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/accounts.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/custom-validators/accounts.ts')
-rw-r--r--server/helpers/custom-validators/accounts.ts13
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'
2import { Response } from 'express' 2import { Response } from 'express'
3import 'express-validator' 3import 'express-validator'
4import * as validator from 'validator' 4import * as validator from 'validator'
5import { database as db } from '../../initializers' 5import { AccountModel } from '../../models/account/account'
6import { AccountInstance } from '../../models'
7import { isUserUsernameValid } from './users' 6import { isUserUsernameValid } from './users'
8 7
9function isAccountNameValid (value: string) { 8function isAccountNameValid (value: string) {
@@ -11,24 +10,24 @@ function isAccountNameValid (value: string) {
11} 10}
12 11
13function isAccountIdExist (id: number | string, res: Response) { 12function 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
25function isLocalAccountNameExist (name: string, res: Response) { 24function 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
31async function isAccountExist (p: Bluebird<AccountInstance>, res: Response) { 30async 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) {