From bcc05e521d3b0017421b7a3ae30a7e5e2b015b87 Mon Sep 17 00:00:00 2001 From: Darcy Ye Date: Thu, 9 Jun 2022 16:24:47 +0800 Subject: [PATCH] feat(core): remove unnecessary variable check and unused route (#1084) --- packages/core/src/routes/session.test.ts | 20 -------------------- packages/core/src/routes/session.ts | 19 ------------------- 2 files changed, 39 deletions(-) diff --git a/packages/core/src/routes/session.test.ts b/packages/core/src/routes/session.test.ts index f9265fd41..587a850cc 100644 --- a/packages/core/src/routes/session.test.ts +++ b/packages/core/src/routes/session.test.ts @@ -543,26 +543,6 @@ describe('sessionRoutes', () => { }); }); - describe('GET /session/register/:username/existence', () => { - it('property existence is false in response if username exists', async () => { - const response = await sessionRequest.get('/session/register/username/existence'); - expect(response.body).toHaveProperty('existence', false); - }); - - it('throw error if username not valid', async () => { - const usernameStartedWithNumber = '1username'; - const response = await sessionRequest.get( - `/session/register/${usernameStartedWithNumber}/existence` - ); - expect(response.statusCode).toEqual(400); - }); - - it('property existence is true in response if username exists', async () => { - const response = await sessionRequest.get('/session/register/username1/existence'); - expect(response.body).toHaveProperty('existence', true); - }); - }); - describe('POST /session/register/passwordless/sms/send-passcode', () => { beforeAll(() => { interactionDetails.mockResolvedValueOnce({ diff --git a/packages/core/src/routes/session.ts b/packages/core/src/routes/session.ts index 8061098e8..d35724d64 100644 --- a/packages/core/src/routes/session.ts +++ b/packages/core/src/routes/session.ts @@ -337,13 +337,6 @@ export default function sessionRoutes(router: T, prov const type = 'RegisterUsernamePassword'; ctx.log(type, { username }); - assertThat( - password, - new RequestError({ - code: 'session.insufficient_info', - status: 400, - }) - ); assertThat( !(await hasUser(username)), new RequestError({ @@ -370,18 +363,6 @@ export default function sessionRoutes(router: T, prov } ); - router.get( - '/session/register/:username/existence', - koaGuard({ params: object({ username: string().regex(usernameRegEx) }) }), - async (ctx, next) => { - const { username } = ctx.guard.params; - - ctx.body = { existence: await hasUser(username) }; - - return next(); - } - ); - router.post( '/session/register/passwordless/sms/send-passcode', koaGuard({ body: object({ phone: string().regex(phoneRegEx) }) }),