From 08a2c53aa0d761aa5130e6565b05f7e1926474cf Mon Sep 17 00:00:00 2001 From: Anand Chowdhary Date: Tue, 18 Aug 2020 18:32:54 +0530 Subject: [PATCH] :recycle: Use Joi.number() for ID --- src/controllers/auth/index.ts | 2 +- src/controllers/organizations/_id/api-keys.ts | 20 +++++++++---------- src/controllers/organizations/_id/billing.ts | 6 +++--- src/controllers/organizations/_id/domains.ts | 20 +++++++++---------- src/controllers/organizations/_id/index.ts | 8 ++++---- src/controllers/organizations/_id/invoices.ts | 6 +++--- .../organizations/_id/memberships.ts | 16 +++++++-------- src/controllers/organizations/_id/sources.ts | 16 +++++++-------- .../organizations/_id/subscriptions.ts | 12 +++++------ .../organizations/_id/transactions.ts | 8 ++++---- src/controllers/organizations/_id/webhooks.ts | 16 +++++++-------- src/controllers/users/_id/access-tokens.ts | 16 +++++++-------- src/controllers/users/_id/emails.ts | 16 +++++++-------- src/controllers/users/_id/identities.ts | 14 ++++++------- src/controllers/users/_id/index.ts | 6 +++--- src/controllers/users/_id/memberships.ts | 14 ++++++------- src/controllers/users/_id/security.ts | 12 +++++------ src/controllers/users/_id/sessions.ts | 10 +++++----- 18 files changed, 109 insertions(+), 109 deletions(-) diff --git a/src/controllers/auth/index.ts b/src/controllers/auth/index.ts index 3466e379c..e03b6cc27 100644 --- a/src/controllers/auth/index.ts +++ b/src/controllers/auth/index.ts @@ -189,7 +189,7 @@ export class AuthController { @Post("impersonate/:id") @Middleware(authHandler) @Middleware( - validator({ impersonateUserId: Joi.string().required() }, "params") + validator({ impersonateUserId: Joi.number().required() }, "params") ) async getImpersonate(req: Request, res: Response) { const tokenUserId = res.locals.token.id; diff --git a/src/controllers/organizations/_id/api-keys.ts b/src/controllers/organizations/_id/api-keys.ts index b97684169..8122dc2dc 100644 --- a/src/controllers/organizations/_id/api-keys.ts +++ b/src/controllers/organizations/_id/api-keys.ts @@ -31,7 +31,7 @@ export class GroupApiKeysController { @Get() async getUserApiKeys(req: Request, res: Response) { const id = twtToId(req.params.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); return getGroupApiKeysForUser(localsToTokenOrKey(res), id, req.query); } @@ -50,7 +50,7 @@ export class GroupApiKeysController { ) async putUserApiKeys(req: Request, res: Response) { const id = twtToId(req.params.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); const added = await createApiKeyForUser( localsToTokenOrKey(res), id, @@ -66,8 +66,8 @@ export class GroupApiKeysController { const apiKeyId = twtToId(req.params.apiKeyId); joiValidate( { - id: Joi.string().required(), - apiKeyId: Joi.string().required(), + id: Joi.number().required(), + apiKeyId: Joi.number().required(), }, { id, apiKeyId } ); @@ -92,8 +92,8 @@ export class GroupApiKeysController { const apiKeyId = twtToId(req.params.apiKeyId); joiValidate( { - id: Joi.string().required(), - apiKeyId: Joi.string().required(), + id: Joi.number().required(), + apiKeyId: Joi.number().required(), }, { id, apiKeyId } ); @@ -113,8 +113,8 @@ export class GroupApiKeysController { const apiKeyId = twtToId(req.params.apiKeyId); joiValidate( { - id: Joi.string().required(), - apiKeyId: Joi.string().required(), + id: Joi.number().required(), + apiKeyId: Joi.number().required(), }, { id, apiKeyId } ); @@ -133,8 +133,8 @@ export class GroupApiKeysController { const apiKeyId = twtToId(req.params.apiKeyId); joiValidate( { - id: Joi.string().required(), - apiKeyId: Joi.string().required(), + id: Joi.number().required(), + apiKeyId: Joi.number().required(), }, { id, apiKeyId } ); diff --git a/src/controllers/organizations/_id/billing.ts b/src/controllers/organizations/_id/billing.ts index 27b23e1bb..b23f02e15 100644 --- a/src/controllers/organizations/_id/billing.ts +++ b/src/controllers/organizations/_id/billing.ts @@ -13,14 +13,14 @@ export class GroupBillingController { @Get() async getBilling(req: Request, res: Response) { const groupId = twtToId(req.params.id); - joiValidate({ groupId: Joi.string().required() }, { groupId }); + joiValidate({ groupId: Joi.number().required() }, { groupId }); return getGroupBillingForUser(localsToTokenOrKey(res), groupId); } @Patch() async patchBilling(req: Request, res: Response) { const groupId = twtToId(req.params.id); - joiValidate({ groupId: Joi.string().required() }, { groupId }); + joiValidate({ groupId: Joi.number().required() }, { groupId }); await updateGroupBillingForUser( localsToTokenOrKey(res), groupId, @@ -35,7 +35,7 @@ export class GroupBillingController { const groupId = twtToId(req.params.id); joiValidate( { - groupId: Joi.string().required(), + groupId: Joi.number().required(), }, { groupId } ); diff --git a/src/controllers/organizations/_id/domains.ts b/src/controllers/organizations/_id/domains.ts index aebf4e7bb..936f24179 100644 --- a/src/controllers/organizations/_id/domains.ts +++ b/src/controllers/organizations/_id/domains.ts @@ -32,7 +32,7 @@ export class GroupDomainsController { @Get() async getUserDomains(req: Request, res: Response) { const id = twtToId(req.params.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); return getGroupDomainsForUser(localsToTokenOrKey(res), id, req.query); } @@ -47,7 +47,7 @@ export class GroupDomainsController { ) async putUserDomains(req: Request, res: Response) { const id = twtToId(req.params.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); const added = await createDomainForUser( localsToTokenOrKey(res), id, @@ -63,8 +63,8 @@ export class GroupDomainsController { const domainId = twtToId(req.params.domainId); joiValidate( { - id: Joi.string().required(), - domainId: Joi.string().required(), + id: Joi.number().required(), + domainId: Joi.number().required(), }, { id, domainId } ); @@ -85,8 +85,8 @@ export class GroupDomainsController { const domainId = twtToId(req.params.domainId); joiValidate( { - id: Joi.string().required(), - domainId: Joi.string().required(), + id: Joi.number().required(), + domainId: Joi.number().required(), }, { id, domainId } ); @@ -106,8 +106,8 @@ export class GroupDomainsController { const domainId = twtToId(req.params.domainId); joiValidate( { - id: Joi.string().required(), - domainId: Joi.string().required(), + id: Joi.number().required(), + domainId: Joi.number().required(), }, { id, domainId } ); @@ -127,8 +127,8 @@ export class GroupDomainsController { const method = req.body.method || req.query.method; joiValidate( { - id: Joi.string().required(), - domainId: Joi.string().required(), + id: Joi.number().required(), + domainId: Joi.number().required(), method: Joi.string().allow("file", "dns").only(), }, { id, domainId, method } diff --git a/src/controllers/organizations/_id/index.ts b/src/controllers/organizations/_id/index.ts index b41b55bcc..8f645b851 100644 --- a/src/controllers/organizations/_id/index.ts +++ b/src/controllers/organizations/_id/index.ts @@ -23,7 +23,7 @@ export class GroupController { @Get() async get(req: Request, res: Response) { const id = twtToId(req.params.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); const group = await getGroupForUser(localsToTokenOrKey(res), id); return group; } @@ -45,7 +45,7 @@ export class GroupController { ) async patch(req: Request, res: Response) { const id = twtToId(req.params.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); const updated = await updateGroupForUser( localsToTokenOrKey(res), id, @@ -58,7 +58,7 @@ export class GroupController { @Delete() async delete(req: Request, res: Response) { const groupId = twtToId(req.params.id); - joiValidate({ groupId: Joi.string().required() }, { groupId }); + joiValidate({ groupId: Joi.number().required() }, { groupId }); await deleteGroupForUser(res.locals.token.id, groupId, res.locals); return respond(RESOURCE_DELETED); } @@ -66,7 +66,7 @@ export class GroupController { @Get("data") async getData(req: Request, res: Response) { const groupId = twtToId(req.params.id); - joiValidate({ groupId: Joi.string().required() }, { groupId }); + joiValidate({ groupId: Joi.number().required() }, { groupId }); return getAllGroupDataForUser(localsToTokenOrKey(res), groupId); } } diff --git a/src/controllers/organizations/_id/invoices.ts b/src/controllers/organizations/_id/invoices.ts index 7c9b2af55..6ea512c3a 100644 --- a/src/controllers/organizations/_id/invoices.ts +++ b/src/controllers/organizations/_id/invoices.ts @@ -12,7 +12,7 @@ export class GroupInvoicesController { @Get() async getInvoices(req: Request, res: Response) { const groupId = twtToId(req.params.id); - joiValidate({ groupId: Joi.string().required() }, { groupId }); + joiValidate({ groupId: Joi.number().required() }, { groupId }); const subscriptionParams = { ...req.query }; joiValidate( { @@ -37,8 +37,8 @@ export class GroupInvoicesController { const invoiceId = req.params.invoiceId; joiValidate( { - groupId: Joi.string().required(), - invoiceId: Joi.string().required(), + groupId: Joi.number().required(), + invoiceId: Joi.number().required(), }, { groupId, invoiceId } ); diff --git a/src/controllers/organizations/_id/memberships.ts b/src/controllers/organizations/_id/memberships.ts index 314b85213..cd9939c72 100644 --- a/src/controllers/organizations/_id/memberships.ts +++ b/src/controllers/organizations/_id/memberships.ts @@ -31,7 +31,7 @@ export class GroupMembershipsController { @Get() async getMemberships(req: Request, res: Response) { const groupId = twtToId(req.params.id); - joiValidate({ groupId: Joi.string().required() }, { groupId }); + joiValidate({ groupId: Joi.number().required() }, { groupId }); return getGroupMembershipsForUser( localsToTokenOrKey(res), groupId, @@ -47,7 +47,7 @@ export class GroupMembershipsController { const role = req.body.role; joiValidate( { - groupId: Joi.string().required(), + groupId: Joi.number().required(), newMemberName: Joi.string().min(6).required(), newMemberEmail: Joi.string().email().required(), role: Joi.number(), @@ -76,8 +76,8 @@ export class GroupMembershipsController { const membershipId = twtToId(req.params.membershipId); joiValidate( { - groupId: Joi.string().required(), - membershipId: Joi.string().required(), + groupId: Joi.number().required(), + membershipId: Joi.number().required(), }, { groupId, membershipId } ); @@ -102,8 +102,8 @@ export class GroupMembershipsController { const membershipId = twtToId(req.params.membershipId); joiValidate( { - groupId: Joi.string().required(), - membershipId: Joi.string().required(), + groupId: Joi.number().required(), + membershipId: Joi.number().required(), }, { groupId, membershipId } ); @@ -122,8 +122,8 @@ export class GroupMembershipsController { const membershipId = twtToId(req.params.membershipId); joiValidate( { - groupId: Joi.string().required(), - membershipId: Joi.string().required(), + groupId: Joi.number().required(), + membershipId: Joi.number().required(), }, { groupId, membershipId } ); diff --git a/src/controllers/organizations/_id/sources.ts b/src/controllers/organizations/_id/sources.ts index 050169024..01522534f 100644 --- a/src/controllers/organizations/_id/sources.ts +++ b/src/controllers/organizations/_id/sources.ts @@ -29,7 +29,7 @@ export class GroupSourcesController { @Get() async getSources(req: Request, res: Response) { const groupId = twtToId(req.params.id); - joiValidate({ groupId: Joi.string().required() }, { groupId }); + joiValidate({ groupId: Joi.number().required() }, { groupId }); const subscriptionParams = { ...req.query }; joiValidate( { @@ -48,7 +48,7 @@ export class GroupSourcesController { @Put() async putSources(req: Request, res: Response) { const groupId = twtToId(req.params.id); - joiValidate({ groupId: Joi.string().required() }, { groupId }); + joiValidate({ groupId: Joi.number().required() }, { groupId }); await createGroupSourceForUser( localsToTokenOrKey(res), groupId, @@ -64,8 +64,8 @@ export class GroupSourcesController { const sourceId = req.params.sourceId; joiValidate( { - groupId: Joi.string().required(), - sourceId: Joi.string().required(), + groupId: Joi.number().required(), + sourceId: Joi.number().required(), }, { groupId, sourceId } ); @@ -78,8 +78,8 @@ export class GroupSourcesController { const groupId = twtToId(req.params.id); joiValidate( { - groupId: Joi.string().required(), - sourceId: Joi.string().required(), + groupId: Joi.number().required(), + sourceId: Joi.number().required(), }, { groupId, sourceId } ); @@ -99,8 +99,8 @@ export class GroupSourcesController { const groupId = twtToId(req.params.id); joiValidate( { - groupId: Joi.string().required(), - sourceId: Joi.string().required(), + groupId: Joi.number().required(), + sourceId: Joi.number().required(), }, { groupId, sourceId } ); diff --git a/src/controllers/organizations/_id/subscriptions.ts b/src/controllers/organizations/_id/subscriptions.ts index f9fab94b1..f09f7f794 100644 --- a/src/controllers/organizations/_id/subscriptions.ts +++ b/src/controllers/organizations/_id/subscriptions.ts @@ -22,7 +22,7 @@ export class GroupSubscriptionsController { @Get() async getSubscriptions(req: Request, res: Response) { const groupId = twtToId(req.params.id); - joiValidate({ groupId: Joi.string().required() }, { groupId }); + joiValidate({ groupId: Joi.number().required() }, { groupId }); const subscriptionParams = { ...req.query }; joiValidate( { @@ -44,7 +44,7 @@ export class GroupSubscriptionsController { @Put() async putSubscriptions(req: Request, res: Response) { const groupId = twtToId(req.params.id); - joiValidate({ groupId: Joi.string().required() }, { groupId }); + joiValidate({ groupId: Joi.number().required() }, { groupId }); const subscriptionParams = { ...req.body }; joiValidate( { @@ -70,8 +70,8 @@ export class GroupSubscriptionsController { const subscriptionId = req.params.subscriptionId; joiValidate( { - groupId: Joi.string().required(), - subscriptionId: Joi.string().required(), + groupId: Joi.number().required(), + subscriptionId: Joi.number().required(), }, { groupId, subscriptionId } ); @@ -89,8 +89,8 @@ export class GroupSubscriptionsController { const data = req.body; joiValidate( { - groupId: Joi.string().required(), - subscriptionId: Joi.string().required(), + groupId: Joi.number().required(), + subscriptionId: Joi.number().required(), }, { groupId, subscriptionId } ); diff --git a/src/controllers/organizations/_id/transactions.ts b/src/controllers/organizations/_id/transactions.ts index 2e1b4a67a..870ba6f75 100644 --- a/src/controllers/organizations/_id/transactions.ts +++ b/src/controllers/organizations/_id/transactions.ts @@ -13,7 +13,7 @@ export class GroupTransactionsController { @Get() async getTransactions(req: Request, res: Response) { const groupId = twtToId(req.params.id); - joiValidate({ groupId: Joi.string().required() }, { groupId }); + joiValidate({ groupId: Joi.number().required() }, { groupId }); const transactionParams = { ...req.query }; joiValidate( { @@ -35,7 +35,7 @@ export class GroupTransactionsController { const couponCode = req.body.couponCode; joiValidate( { - groupId: Joi.string().required(), + groupId: Joi.number().required(), couponCode: Joi.string().required(), }, { groupId, couponCode } @@ -53,8 +53,8 @@ export class GroupTransactionsController { const transactionId = req.params.transactionId; joiValidate( { - groupId: Joi.string().required(), - transactionId: Joi.string().required(), + groupId: Joi.number().required(), + transactionId: Joi.number().required(), }, { groupId, transactionId } ); diff --git a/src/controllers/organizations/_id/webhooks.ts b/src/controllers/organizations/_id/webhooks.ts index 2187a3174..8233c914b 100644 --- a/src/controllers/organizations/_id/webhooks.ts +++ b/src/controllers/organizations/_id/webhooks.ts @@ -30,7 +30,7 @@ export class GroupWebhooksController { @Get() async getGroupWebhooks(req: Request, res: Response) { const id = twtToId(req.params.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); return getGroupWebhooksForUser(localsToTokenOrKey(res), id, req.query); } @@ -49,7 +49,7 @@ export class GroupWebhooksController { ) async putGroupWebhooks(req: Request, res: Response) { const id = twtToId(req.params.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); const added = await createWebhookForUser( localsToTokenOrKey(res), id, @@ -65,8 +65,8 @@ export class GroupWebhooksController { const webhookId = twtToId(req.params.webhookId); joiValidate( { - id: Joi.string().required(), - webhookId: Joi.string().required(), + id: Joi.number().required(), + webhookId: Joi.number().required(), }, { id, webhookId } ); @@ -91,8 +91,8 @@ export class GroupWebhooksController { const webhookId = twtToId(req.params.webhookId); joiValidate( { - id: Joi.string().required(), - webhookId: Joi.string().required(), + id: Joi.number().required(), + webhookId: Joi.number().required(), }, { id, webhookId } ); @@ -112,8 +112,8 @@ export class GroupWebhooksController { const webhookId = twtToId(req.params.webhookId); joiValidate( { - id: Joi.string().required(), - webhookId: Joi.string().required(), + id: Joi.number().required(), + webhookId: Joi.number().required(), }, { id, webhookId } ); diff --git a/src/controllers/users/_id/access-tokens.ts b/src/controllers/users/_id/access-tokens.ts index 7f04c4642..891cf43c0 100644 --- a/src/controllers/users/_id/access-tokens.ts +++ b/src/controllers/users/_id/access-tokens.ts @@ -30,7 +30,7 @@ export class UserAccessTokensController { @Get() async getUserAccessTokens(req: Request, res: Response) { const id = twtToId(req.params.id, res.locals.token.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); return getUserAccessTokensForUser(res.locals.token.id, id, req.query); } @@ -48,7 +48,7 @@ export class UserAccessTokensController { ) async putUserAccessTokens(req: Request, res: Response) { const id = twtToId(req.params.id, res.locals.token.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); try { const added = await createAccessTokenForUser( res.locals.token.id, @@ -69,8 +69,8 @@ export class UserAccessTokensController { const accessTokenId = twtToId(req.params.accessTokenId); joiValidate( { - id: Joi.string().required(), - accessTokenId: Joi.string().required(), + id: Joi.number().required(), + accessTokenId: Joi.number().required(), }, { id, accessTokenId } ); @@ -94,8 +94,8 @@ export class UserAccessTokensController { const accessTokenId = twtToId(req.params.accessTokenId); joiValidate( { - id: Joi.string().required(), - accessTokenId: Joi.string().required(), + id: Joi.number().required(), + accessTokenId: Joi.number().required(), }, { id, accessTokenId } ); @@ -115,8 +115,8 @@ export class UserAccessTokensController { const accessTokenId = twtToId(req.params.accessTokenId); joiValidate( { - id: Joi.string().required(), - accessTokenId: Joi.string().required(), + id: Joi.number().required(), + accessTokenId: Joi.number().required(), }, { id, accessTokenId } ); diff --git a/src/controllers/users/_id/emails.ts b/src/controllers/users/_id/emails.ts index b5bb43ef8..64c1ee4fe 100644 --- a/src/controllers/users/_id/emails.ts +++ b/src/controllers/users/_id/emails.ts @@ -29,7 +29,7 @@ export class UserEmailsController { @Get() async getEmails(req: Request, res: Response) { const id = twtToId(req.params.id, res.locals.token.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); return getAllEmailsForUser(res.locals.token.id, id, req.query); } @@ -39,7 +39,7 @@ export class UserEmailsController { const email = req.body.email; joiValidate( { - id: Joi.string().required(), + id: Joi.number().required(), email: Joi.string().email().required(), }, { id, email } @@ -59,8 +59,8 @@ export class UserEmailsController { const emailId = twtToId(req.params.emailId); joiValidate( { - id: Joi.string().required(), - emailId: Joi.string().required(), + id: Joi.number().required(), + emailId: Joi.number().required(), }, { id, emailId } ); @@ -73,8 +73,8 @@ export class UserEmailsController { const emailId = twtToId(req.params.emailId); joiValidate( { - id: Joi.string().required(), - emailId: Joi.string().required(), + id: Joi.number().required(), + emailId: Joi.number().required(), }, { id, emailId } ); @@ -88,8 +88,8 @@ export class UserEmailsController { const emailId = twtToId(req.params.emailId); joiValidate( { - id: Joi.string().required(), - emailId: Joi.string().required(), + id: Joi.number().required(), + emailId: Joi.number().required(), }, { id, emailId } ); diff --git a/src/controllers/users/_id/identities.ts b/src/controllers/users/_id/identities.ts index 42005ce33..8b710141a 100644 --- a/src/controllers/users/_id/identities.ts +++ b/src/controllers/users/_id/identities.ts @@ -29,14 +29,14 @@ export class UserIdentitiesController { @Get() async getUserIdentities(req: Request, res: Response) { const id = twtToId(req.params.id, res.locals.token.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); return getUserIdentitiesForUser(res.locals.token.id, id, req.query); } @Put() async createUserIdentity(req: Request, res: Response) { const id = twtToId(req.params.id, res.locals.token.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); const added = await createUserIdentityForUser( res.locals.token.id, id, @@ -48,7 +48,7 @@ export class UserIdentitiesController { @Post(":service") async connectUserIdentity(req: Request, res: Response) { const id = twtToId(req.params.id, res.locals.token.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); const service = req.params.service; const url = req.body.url; joiValidate( @@ -65,8 +65,8 @@ export class UserIdentitiesController { const identityId = twtToId(req.params.identityId); joiValidate( { - id: Joi.string().required(), - identityId: Joi.string().required(), + id: Joi.number().required(), + identityId: Joi.number().required(), }, { id, identityId } ); @@ -79,8 +79,8 @@ export class UserIdentitiesController { const identityId = twtToId(req.params.identityId); joiValidate( { - id: Joi.string().required(), - identityId: Joi.string().required(), + id: Joi.number().required(), + identityId: Joi.number().required(), }, { id, identityId } ); diff --git a/src/controllers/users/_id/index.ts b/src/controllers/users/_id/index.ts index c557f6286..e7b142f3f 100644 --- a/src/controllers/users/_id/index.ts +++ b/src/controllers/users/_id/index.ts @@ -22,7 +22,7 @@ export class UserController { @Get() async get(req: Request, res: Response) { const id = twtToId(req.params.id, res.locals.token.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); return getUserFromIdForUser(id, res.locals.token.id, req.query); } @@ -60,7 +60,7 @@ export class UserController { ) async patch(req: Request, res: Response) { const id = twtToId(req.params.id, res.locals.token.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); const updated = await updateUserForUser( res.locals.token.id, id, @@ -73,7 +73,7 @@ export class UserController { @Delete() async delete(req: Request, res: Response) { const id = twtToId(req.params.id, res.locals.token.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); await deleteUserForUser(res.locals.token.id, id, res.locals); return respond(RESOURCE_DELETED); } diff --git a/src/controllers/users/_id/memberships.ts b/src/controllers/users/_id/memberships.ts index f5e53d835..1759d1683 100644 --- a/src/controllers/users/_id/memberships.ts +++ b/src/controllers/users/_id/memberships.ts @@ -22,7 +22,7 @@ export class UserMembershipsController { @Get() async getMemberships(req: Request, res: Response) { const id = twtToId(req.params.id, res.locals.token.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); return getMembershipsForUser(res.locals.token.id, id, req.query); } @@ -32,8 +32,8 @@ export class UserMembershipsController { const membershipId = twtToId(req.params.membershipId); joiValidate( { - id: Joi.string().required(), - membershipId: Joi.string().required(), + id: Joi.number().required(), + membershipId: Joi.number().required(), }, { id, membershipId } ); @@ -46,8 +46,8 @@ export class UserMembershipsController { const membershipId = twtToId(req.params.membershipId); joiValidate( { - id: Joi.string().required(), - membershipId: Joi.string().required(), + id: Joi.number().required(), + membershipId: Joi.number().required(), }, { id, membershipId } ); @@ -61,8 +61,8 @@ export class UserMembershipsController { const membershipId = twtToId(req.params.membershipId); joiValidate( { - id: Joi.string().required(), - membershipId: Joi.string().required(), + id: Joi.number().required(), + membershipId: Joi.number().required(), }, { id, membershipId } ); diff --git a/src/controllers/users/_id/security.ts b/src/controllers/users/_id/security.ts index 9ddfc7deb..e162c0478 100644 --- a/src/controllers/users/_id/security.ts +++ b/src/controllers/users/_id/security.ts @@ -39,7 +39,7 @@ export class UserSecurityController { const newPassword = req.body.newPassword; joiValidate( { - id: Joi.string().required(), + id: Joi.number().required(), }, { id } ); @@ -56,14 +56,14 @@ export class UserSecurityController { @Get("data") async getUserData(req: Request, res: Response) { const id = twtToId(req.params.id, res.locals.token.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); return getAllDataForUser(res.locals.token.id, id); } @Get("2fa/enable") async getEnable2FA(req: Request, res: Response) { const id = twtToId(req.params.id, res.locals.token.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); return enable2FAForUser(res.locals.token.id, id); } @@ -73,7 +73,7 @@ export class UserSecurityController { const code = req.body.code; joiValidate( { - id: Joi.string().required(), + id: Joi.number().required(), code: Joi.number().min(5).required(), }, { id, code } @@ -85,7 +85,7 @@ export class UserSecurityController { @Delete("2fa") async delete2FA(req: Request, res: Response) { const id = twtToId(req.params.id, res.locals.token.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); await disable2FAForUser(res.locals.token.id, id); return respond(RESOURCE_SUCCESS); } @@ -93,7 +93,7 @@ export class UserSecurityController { @Get("backup-codes/regenerate") async getRegenerateBackupCodes(req: Request, res: Response) { const id = twtToId(req.params.id, res.locals.token.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); const backupCodes = await regenerateBackupCodesForUser( res.locals.token.id, id diff --git a/src/controllers/users/_id/sessions.ts b/src/controllers/users/_id/sessions.ts index 6d5b079a1..a3e4e1993 100644 --- a/src/controllers/users/_id/sessions.ts +++ b/src/controllers/users/_id/sessions.ts @@ -20,7 +20,7 @@ export class UserSessionsController { @Get() async getUserSessions(req: Request, res: Response) { const id = twtToId(req.params.id, res.locals.token.id); - joiValidate({ id: Joi.string().required() }, { id }); + joiValidate({ id: Joi.number().required() }, { id }); return getUserSessionsForUser(res.locals.token.id, id, req.query); } @@ -30,8 +30,8 @@ export class UserSessionsController { const sessionId = twtToId(req.params.sessionId); joiValidate( { - id: Joi.string().required(), - sessionId: Joi.string().required(), + id: Joi.number().required(), + sessionId: Joi.number().required(), }, { id, sessionId } ); @@ -44,8 +44,8 @@ export class UserSessionsController { const sessionId = twtToId(req.params.sessionId); joiValidate( { - id: Joi.string().required(), - sessionId: Joi.string().required(), + id: Joi.number().required(), + sessionId: Joi.number().required(), }, { id, sessionId } );