@things-factory/auth-base 8.0.0-alpha.29 → 8.0.0-alpha.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/constants/error-code.d.ts +2 -0
- package/dist-server/constants/error-code.js +3 -1
- package/dist-server/constants/error-code.js.map +1 -1
- package/dist-server/controllers/change-pwd.js +2 -2
- package/dist-server/controllers/change-pwd.js.map +1 -1
- package/dist-server/controllers/delete-user.js +13 -12
- package/dist-server/controllers/delete-user.js.map +1 -1
- package/dist-server/controllers/invitation.d.ts +2 -1
- package/dist-server/controllers/invitation.js +30 -5
- package/dist-server/controllers/invitation.js.map +1 -1
- package/dist-server/controllers/profile.d.ts +4 -3
- package/dist-server/controllers/profile.js +20 -2
- package/dist-server/controllers/profile.js.map +1 -1
- package/dist-server/controllers/signin.d.ts +4 -1
- package/dist-server/controllers/signin.js +17 -1
- package/dist-server/controllers/signin.js.map +1 -1
- package/dist-server/controllers/signup.js +13 -4
- package/dist-server/controllers/signup.js.map +1 -1
- package/dist-server/controllers/unlock-user.js +1 -0
- package/dist-server/controllers/unlock-user.js.map +1 -1
- package/dist-server/controllers/verification.js +1 -0
- package/dist-server/controllers/verification.js.map +1 -1
- package/dist-server/middlewares/signin-middleware.js +3 -3
- package/dist-server/middlewares/signin-middleware.js.map +1 -1
- package/dist-server/migrations/1548206416130-SeedUser.js +2 -1
- package/dist-server/migrations/1548206416130-SeedUser.js.map +1 -1
- package/dist-server/router/auth-checkin-router.js +8 -2
- package/dist-server/router/auth-checkin-router.js.map +1 -1
- package/dist-server/router/auth-private-process-router.js +12 -7
- package/dist-server/router/auth-private-process-router.js.map +1 -1
- package/dist-server/router/auth-public-process-router.js +20 -9
- package/dist-server/router/auth-public-process-router.js.map +1 -1
- package/dist-server/router/auth-signin-router.js +3 -3
- package/dist-server/router/auth-signin-router.js.map +1 -1
- package/dist-server/service/invitation/invitation-mutation.d.ts +3 -2
- package/dist-server/service/invitation/invitation-mutation.js +20 -8
- package/dist-server/service/invitation/invitation-mutation.js.map +1 -1
- package/dist-server/service/user/user-mutation.d.ts +10 -9
- package/dist-server/service/user/user-mutation.js +112 -54
- package/dist-server/service/user/user-mutation.js.map +1 -1
- package/dist-server/service/user/user-types.d.ts +1 -0
- package/dist-server/service/user/user-types.js +4 -0
- package/dist-server/service/user/user-types.js.map +1 -1
- package/dist-server/service/user/user.d.ts +1 -0
- package/dist-server/service/user/user.js +40 -14
- package/dist-server/service/user/user.js.map +1 -1
- package/dist-server/templates/account-unlock-email.d.ts +2 -1
- package/dist-server/templates/account-unlock-email.js +1 -1
- package/dist-server/templates/account-unlock-email.js.map +1 -1
- package/dist-server/templates/invitation-email.d.ts +2 -1
- package/dist-server/templates/invitation-email.js +1 -1
- package/dist-server/templates/invitation-email.js.map +1 -1
- package/dist-server/templates/verification-email.d.ts +2 -1
- package/dist-server/templates/verification-email.js +1 -1
- package/dist-server/templates/verification-email.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/server/constants/error-code.ts +2 -0
- package/server/controllers/change-pwd.ts +3 -2
- package/server/controllers/delete-user.ts +16 -13
- package/server/controllers/invitation.ts +36 -5
- package/server/controllers/profile.ts +29 -2
- package/server/controllers/signin.ts +21 -2
- package/server/controllers/signup.ts +16 -4
- package/server/controllers/unlock-user.ts +1 -0
- package/server/controllers/verification.ts +1 -0
- package/server/middlewares/signin-middleware.ts +3 -3
- package/server/migrations/1548206416130-SeedUser.ts +2 -1
- package/server/router/auth-checkin-router.ts +11 -5
- package/server/router/auth-private-process-router.ts +14 -7
- package/server/router/auth-public-process-router.ts +22 -10
- package/server/router/auth-signin-router.ts +3 -3
- package/server/service/invitation/invitation-mutation.ts +24 -9
- package/server/service/user/user-mutation.ts +123 -54
- package/server/service/user/user-types.ts +3 -0
- package/server/service/user/user.ts +41 -14
- package/server/templates/account-unlock-email.ts +1 -1
- package/server/templates/invitation-email.ts +1 -1
- package/server/templates/verification-email.ts +1 -1
- package/translations/en.json +5 -1
- package/translations/ja.json +5 -1
- package/translations/ko.json +6 -3
- package/translations/ms.json +5 -1
- package/translations/zh.json +5 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"auth-public-process-router.js","sourceRoot":"","sources":["../../server/router/auth-public-process-router.ts"],"names":[],"mappings":";;;;AAAA,oEAA+B;AAE/B,6CAA4C;AAC5C,iDAAsE;AAEtE,0DAAiE;AACjE,kEAAqF;AACrF,4DAAuD;AACvD,8DAA6E;AAC7E,+CAA2C;AAC3C,8CAA0C;AAC1C,sEAAqE;AAErE,MAAM,wBAAwB,GAAG,YAAM,CAAC,GAAG,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAA;AAC9E,MAAM,0BAA0B,GAAG,YAAM,CAAC,GAAG,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAA;AACvF,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;AACrD,MAAM,YAAY,GAAG,YAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI;IAC7C,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,KAAK,EAAE,IAAI;IACX,gBAAgB,EAAE,IAAI;IACtB,WAAW,EAAE,KAAK;IAClB,eAAe,EAAE,IAAI;IACrB,eAAe,EAAE,KAAK;IACtB,oBAAoB,EAAE,CAAC;IACvB,oBAAoB,EAAE,EAAE;CACzB,CAAA;AAEY,QAAA,uBAAuB,GAAG,IAAI,oBAAM,CAAC;IAChD,MAAM,EAAE,OAAO;CAChB,CAAC,CAAA;AAEF,+BAAuB,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAC5D,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAA;IAE5C,MAAM,IAAI,GAAS,MA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AO,CAAC,MAAM,CAAC,WAAW,EAAE;YAChC,WAAW,EAAE,aAAa;YAC1B,aAAa,EAAE,iBAAiB;YAChC,IAAI,EAAE;gBACJ,OAAO,EAAE,CAAC,CAAC,6BAA6B,CAAC;gBACzC,wBAAwB;gBACxB,0BAA0B;gBAC1B,SAAS;aACV;SACF,CAAC,CAAA;IACJ,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["import Router from 'koa-router'\n\nimport { config } from '@things-factory/env'\nimport { getRepository, getSiteRootPath } from '@things-factory/shell'\n\nimport { resendInvitationEmail } from '../controllers/invitation'\nimport { resetPassword, sendPasswordResetEmail } from '../controllers/reset-password'\nimport { unlockUser } from '../controllers/unlock-user'\nimport { resendVerificationEmail, verify } from '../controllers/verification'\nimport { User } from '../service/user/user'\nimport { accepts } from '../utils/accepts'\nimport { clearAccessTokenCookie } from '../utils/access-token-cookie'\n\nconst disableUserSignupProcess = config.get('disableUserSignupProcess', false)\nconst disableUserFavoredLanguage = config.get('i18n/disableUserFavoredLanguage', false)\nconst languages = config.get('i18n/languages', false)\nconst passwordRule = config.get('password') || {\n lowerCase: true,\n upperCase: true,\n digit: true,\n specialCharacter: true,\n allowRepeat: false,\n useTightPattern: true,\n useLoosePattern: false,\n tightCharacterLength: 8,\n looseCharacterLength: 15\n}\n\nexport const authPublicProcessRouter = new Router({\n prefix: '/auth'\n})\n\nauthPublicProcessRouter.post('/join', async (context, next) => {\n const { email } = context.request.body || {}\n\n const user: User = await getRepository(User).findOneBy({\n email\n })\n\n if (user) {\n context.redirect(`/auth/signin?email=${email}`)\n } else {\n context.redirect(`/auth/signup?email=${email}`)\n }\n})\n\nauthPublicProcessRouter.all('/signout', async (context, next) => {\n const { header, t } = context\n clearAccessTokenCookie(context)\n\n context.body = t('text.signout successfully')\n\n if (accepts(header.accept, ['text/html', '*/*'])) {\n context.redirect(getSiteRootPath(context))\n }\n})\n\nauthPublicProcessRouter.get('/forgot-password', async (context, next) => {\n const { email } = context.request.query\n\n await context.render('auth-page', {\n pageElement: 'forgot-password',\n elementScript: '/auth/forgot-password.js',\n data: {\n email,\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n})\n\nauthPublicProcessRouter.get('/reset-password', async (context, next) => {\n const { token } = context.request.query\n\n await context.render('auth-page', {\n pageElement: 'reset-password',\n elementScript: '/auth/reset-password.js',\n data: {\n token,\n passwordRule,\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n})\n\nauthPublicProcessRouter.get('/unlock-user', async (context, next) => {\n const { token } = context.request.query\n\n await context.render('auth-page', {\n pageElement: 'unlock-user',\n elementScript: '/auth/unlock-user.js',\n data: {\n token,\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n})\n\nauthPublicProcessRouter.get('/activate/:email', async (context, next) => {\n const { email } = context.params\n\n await context.render('auth-page', {\n pageElement: 'auth-activate',\n elementScript: '/auth/activate.js',\n data: {\n email,\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n})\n\nauthPublicProcessRouter.get('/verify/:token', async (context, next) => {\n const { header, t } = context\n var token = context.params.token\n\n await verify(token)\n\n var message = t('text.user activated successfully')\n\n context.body = message\n\n if (accepts(header.accept, ['text/html', '*/*'])) {\n await context.render('auth-page', {\n pageElement: 'auth-result',\n elementScript: '/auth/result.js',\n data: {\n message,\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n }\n})\n\nauthPublicProcessRouter.post('/resend-verification-email', async (context, next) => {\n const { t } = context\n const { email } = context.request.body\n\n var succeed = await resendVerificationEmail(email, context)\n var message = t('text.verification email sent')\n\n if (succeed) {\n context.status = 200\n context.body = message\n }\n})\n\nauthPublicProcessRouter.post('/resend-invitation-email', async (context, next) => {\n const { t } = context\n const { email, reference, type } = context.request.body\n\n var succeed = await resendInvitationEmail(\n {\n email,\n reference,\n type\n },\n context\n )\n\n var message = t('text.invitation email sent')\n\n if (succeed) {\n context.status = 200\n context.body = message\n }\n})\n\nauthPublicProcessRouter.post('/forgot-password', async (context, next) => {\n const { t } = context\n const { email } = context.request.body\n\n if (!email) return next()\n\n const userRepo = getRepository(User)\n const user = await userRepo.findOne({\n where: {\n email\n }\n })\n\n const succeed = await sendPasswordResetEmail({\n user,\n context\n })\n\n if (succeed) {\n context.status = 200\n context.body = t('text.password reset email sent')\n }\n})\n\nauthPublicProcessRouter.post('/reset-password', async (context, next) => {\n const { header, t } = context\n\n try {\n const { password, token } = context.request.body\n\n if (!(token && password)) {\n let message = t('error.token or password is invalid')\n\n context.status = 404\n context.body = {\n message\n }\n\n if (accepts(header.accept, ['text/html', '*/*'])) {\n await context.render('auth-page', {\n pageElement: 'reset-password',\n elementScript: '/auth/reset-password.js',\n data: {\n token,\n message,\n passwordRule,\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n }\n\n return\n }\n\n await resetPassword(token, password, context)\n\n var message = t('text.password reset succeed')\n context.body = message\n\n clearAccessTokenCookie(context)\n\n if (accepts(header.accept, ['text/html', '*/*'])) {\n await context.render('auth-page', {\n pageElement: 'auth-result',\n elementScript: '/auth/result.js',\n data: {\n message,\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n }\n } catch (e) {\n context.status = 404\n context.body = e.message\n\n if (accepts(header.accept, ['text/html', '*/*'])) {\n await context.render('auth-page', {\n pageElement: 'auth-result',\n elementScript: '/auth/result.js',\n data: {\n message: e.message,\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n }\n }\n})\n\nauthPublicProcessRouter.post('/unlock-user', async (context, next) => {\n const { header, t } = context\n const { password, token } = context.request.body\n\n if (!(token || password)) {\n context.status = 404\n context.body = t('error.token or password is invalid')\n\n return\n }\n\n var succeed = await unlockUser(token, password)\n\n if (succeed) {\n context.body = t('text.password reset succeed')\n\n clearAccessTokenCookie(context)\n }\n\n if (accepts(header.accept, ['text/html', '*/*'])) {\n await context.render('auth-page', {\n pageElement: 'auth-result',\n elementScript: '/auth/result.js',\n data: {\n message: t('text.account is reactivated'),\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n }\n})\n"]}
|
1
|
+
{"version":3,"file":"auth-public-process-router.js","sourceRoot":"","sources":["../../server/router/auth-public-process-router.ts"],"names":[],"mappings":";;;;AAAA,oEAA+B;AAC/B,qCAA+B;AAE/B,6CAA4C;AAC5C,iDAAsE;AAEtE,0DAAiE;AACjE,kEAAqF;AACrF,4DAAuD;AACvD,8DAA6E;AAC7E,+CAA2C;AAC3C,8CAA0C;AAC1C,sEAAqE;AAErE,MAAM,wBAAwB,GAAG,YAAM,CAAC,GAAG,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAA;AAC9E,MAAM,0BAA0B,GAAG,YAAM,CAAC,GAAG,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAA;AACvF,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;AACrD,MAAM,YAAY,GAAG,YAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI;IAC7C,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,KAAK,EAAE,IAAI;IACX,gBAAgB,EAAE,IAAI;IACtB,WAAW,EAAE,KAAK;IAClB,eAAe,EAAE,IAAI;IACrB,eAAe,EAAE,KAAK;IACtB,oBAAoB,EAAE,CAAC;IACvB,oBAAoB,EAAE,EAAE;CACzB,CAAA;AAEY,QAAA,uBAAuB,GAAG,IAAI,oBAAM,CAAC;IAChD,MAAM,EAAE,OAAO;CAChB,CAAC,CAAA;AAEF,+BAAuB,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAC5D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAA;IAE/C,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,WAAI,CAAC,CAAA;IAEtC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ACR,CAAC;IAED,IAAI,OAAO,GAAG,MAAM,IAAA,wBAAU,EAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;IAE/C,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,6BAA6B,CAAC,CAAA;QAE/C,IAAA,4CAAsB,EAAC,OAAO,CAAC,CAAA;IACjC,CAAC;IAED,IAAI,IAAA,iBAAO,EAAC,MAAM,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;QACjD,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE;YAChC,WAAW,EAAE,aAAa;YAC1B,aAAa,EAAE,iBAAiB;YAChC,IAAI,EAAE;gBACJ,OAAO,EAAE,CAAC,CAAC,6BAA6B,CAAC;gBACzC,wBAAwB;gBACxB,0BAA0B;gBAC1B,SAAS;aACV;SACF,CAAC,CAAA;IACJ,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["import Router from 'koa-router'\nimport { ILike } from 'typeorm'\n\nimport { config } from '@things-factory/env'\nimport { getRepository, getSiteRootPath } from '@things-factory/shell'\n\nimport { resendInvitationEmail } from '../controllers/invitation'\nimport { resetPassword, sendPasswordResetEmail } from '../controllers/reset-password'\nimport { unlockUser } from '../controllers/unlock-user'\nimport { resendVerificationEmail, verify } from '../controllers/verification'\nimport { User } from '../service/user/user'\nimport { accepts } from '../utils/accepts'\nimport { clearAccessTokenCookie } from '../utils/access-token-cookie'\n\nconst disableUserSignupProcess = config.get('disableUserSignupProcess', false)\nconst disableUserFavoredLanguage = config.get('i18n/disableUserFavoredLanguage', false)\nconst languages = config.get('i18n/languages', false)\nconst passwordRule = config.get('password') || {\n lowerCase: true,\n upperCase: true,\n digit: true,\n specialCharacter: true,\n allowRepeat: false,\n useTightPattern: true,\n useLoosePattern: false,\n tightCharacterLength: 8,\n looseCharacterLength: 15\n}\n\nexport const authPublicProcessRouter = new Router({\n prefix: '/auth'\n})\n\nauthPublicProcessRouter.post('/join', async (context, next) => {\n const { username } = context.request.body || {}\n\n const repository = getRepository(User)\n\n var user = await repository.findOne({\n where: { username },\n relations: ['domains']\n })\n\n if (!user && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(username)) {\n user = await repository.findOne({\n where: { email: ILike(username) },\n relations: ['domains']\n })\n }\n\n if (user) {\n context.redirect(`/auth/signin?username=${username}`)\n } else {\n context.redirect(`/auth/signup?username=${username}`)\n }\n})\n\nauthPublicProcessRouter.all('/signout', async (context, next) => {\n const { header, t } = context\n clearAccessTokenCookie(context)\n\n context.body = t('text.signout successfully')\n\n if (accepts(header.accept, ['text/html', '*/*'])) {\n context.redirect(getSiteRootPath(context))\n }\n})\n\nauthPublicProcessRouter.get('/forgot-password', async (context, next) => {\n const { email } = context.request.query\n\n await context.render('auth-page', {\n pageElement: 'forgot-password',\n elementScript: '/auth/forgot-password.js',\n data: {\n email,\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n})\n\nauthPublicProcessRouter.get('/reset-password', async (context, next) => {\n const { token } = context.request.query\n\n await context.render('auth-page', {\n pageElement: 'reset-password',\n elementScript: '/auth/reset-password.js',\n data: {\n token,\n passwordRule,\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n})\n\nauthPublicProcessRouter.get('/unlock-user', async (context, next) => {\n const { token } = context.request.query\n\n await context.render('auth-page', {\n pageElement: 'unlock-user',\n elementScript: '/auth/unlock-user.js',\n data: {\n token,\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n})\n\nauthPublicProcessRouter.get('/activate/:email', async (context, next) => {\n const { email } = context.params\n\n await context.render('auth-page', {\n pageElement: 'auth-activate',\n elementScript: '/auth/activate.js',\n data: {\n email,\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n})\n\nauthPublicProcessRouter.get('/verify/:token', async (context, next) => {\n const { header, t } = context\n var token = context.params.token\n\n await verify(token)\n\n var message = t('text.user activated successfully')\n\n context.body = message\n\n if (accepts(header.accept, ['text/html', '*/*'])) {\n await context.render('auth-page', {\n pageElement: 'auth-result',\n elementScript: '/auth/result.js',\n data: {\n message,\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n }\n})\n\nauthPublicProcessRouter.post('/resend-verification-email', async (context, next) => {\n const { t } = context\n const { email } = context.request.body\n\n var succeed = await resendVerificationEmail(email, context)\n var message = t('text.verification email sent')\n\n if (succeed) {\n context.status = 200\n context.body = message\n }\n})\n\nauthPublicProcessRouter.post('/resend-invitation-email', async (context, next) => {\n const { t } = context\n const { email, reference, type } = context.request.body\n\n var succeed = await resendInvitationEmail(\n {\n email,\n reference,\n type\n },\n context\n )\n\n var message = t('text.invitation email sent')\n\n if (succeed) {\n context.status = 200\n context.body = message\n }\n})\n\nauthPublicProcessRouter.post('/forgot-password', async (context, next) => {\n const { t } = context\n const { email } = context.request.body\n\n if (!email) return next()\n\n const userRepo = getRepository(User)\n const user = await userRepo.findOne({\n where: {\n email\n }\n })\n\n const succeed = await sendPasswordResetEmail({\n user,\n context\n })\n\n if (succeed) {\n context.status = 200\n context.body = t('text.password reset email sent')\n }\n})\n\nauthPublicProcessRouter.post('/reset-password', async (context, next) => {\n const { header, t } = context\n const { password, token } = context.request.body\n\n try {\n if (!(token && password)) {\n let message = t('error.token or password is invalid')\n\n context.status = 404\n context.body = {\n message\n }\n\n if (accepts(header.accept, ['text/html', '*/*'])) {\n await context.render('auth-page', {\n pageElement: 'reset-password',\n elementScript: '/auth/reset-password.js',\n data: {\n token,\n message,\n passwordRule,\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n }\n\n return\n }\n\n await resetPassword(token, password, context)\n\n var message = t('text.password changed successfully')\n context.body = message\n\n clearAccessTokenCookie(context)\n\n if (accepts(header.accept, ['text/html', '*/*'])) {\n await context.render('auth-page', {\n pageElement: 'auth-result',\n elementScript: '/auth/result.js',\n data: {\n message,\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n }\n } catch (e) {\n context.status = 404\n context.body = e.message\n\n if (accepts(header.accept, ['text/html', '*/*'])) {\n await context.render('auth-page', {\n pageElement: 'reset-password',\n elementScript: '/auth/reset-password.js',\n data: {\n token,\n message: e.message,\n passwordRule,\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n }\n }\n})\n\nauthPublicProcessRouter.post('/unlock-user', async (context, next) => {\n const { header, t } = context\n const { password, token } = context.request.body\n\n if (!(token || password)) {\n context.status = 404\n context.body = t('error.token or password is invalid')\n\n return\n }\n\n var succeed = await unlockUser(token, password)\n\n if (succeed) {\n context.body = t('text.password reset succeed')\n\n clearAccessTokenCookie(context)\n }\n\n if (accepts(header.accept, ['text/html', '*/*'])) {\n await context.render('auth-page', {\n pageElement: 'auth-result',\n elementScript: '/auth/result.js',\n data: {\n message: t('text.account is reactivated'),\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n }\n})\n"]}
|
@@ -18,12 +18,12 @@ const SSOLinks = Object.values(SSOConfig)
|
|
18
18
|
});
|
19
19
|
exports.authSigninRouter = new koa_router_1.default();
|
20
20
|
exports.authSigninRouter.get('/auth/signin', async (context, next) => {
|
21
|
-
const { redirect_to,
|
21
|
+
const { redirect_to, username } = context.query;
|
22
22
|
await context.render('auth-page', {
|
23
23
|
pageElement: 'auth-signin',
|
24
24
|
elementScript: '/auth/signin.js',
|
25
25
|
data: {
|
26
|
-
|
26
|
+
username,
|
27
27
|
redirectTo: redirect_to,
|
28
28
|
ssoLinks: SSOLinks,
|
29
29
|
disableUserSignupProcess,
|
@@ -34,7 +34,7 @@ exports.authSigninRouter.get('/auth/signin', async (context, next) => {
|
|
34
34
|
});
|
35
35
|
exports.authSigninRouter.post('/auth/signin', middlewares_1.signinMiddleware, async (context, next) => {
|
36
36
|
const { request, t } = context;
|
37
|
-
const { token,
|
37
|
+
const { token, domain } = context.state;
|
38
38
|
const { body: reqBody, header } = request;
|
39
39
|
if (!(0, accepts_1.accepts)(header.accept, ['text/html', '*/*'])) {
|
40
40
|
context.body = token;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"auth-signin-router.js","sourceRoot":"","sources":["../../server/router/auth-signin-router.ts"],"names":[],"mappings":";;;;AAAA,oEAA+B;AAE/B,6CAA4C;AAC5C,gDAAiD;AACjD,8CAA0C;AAC1C,sEAAmE;AAEnE,MAAM,wBAAwB,GAAG,YAAM,CAAC,GAAG,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAA;AAC9E,MAAM,0BAA0B,GAAG,YAAM,CAAC,GAAG,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAA;AACvF,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;AAErD,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,KAAK,EAAE,EAAS,CAAC,CAAA;AAC9C,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;KACtC,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,IAAI,IAAI,KAAK,CAAC;KAC1C,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;IACvB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AACxB,CAAC,CAAC,CAAA;AAES,QAAA,gBAAgB,GAAG,IAAI,oBAAM,EAAE,CAAA;AAE5C,wBAAgB,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAC3D,MAAM,EAAE,WAAW,EAAE,
|
1
|
+
{"version":3,"file":"auth-signin-router.js","sourceRoot":"","sources":["../../server/router/auth-signin-router.ts"],"names":[],"mappings":";;;;AAAA,oEAA+B;AAE/B,6CAA4C;AAC5C,gDAAiD;AACjD,8CAA0C;AAC1C,sEAAmE;AAEnE,MAAM,wB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AAE,GAAG,OAAO,CAAA;IAC9B,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IACvC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;IAEzC,IAAI,CAAC,IAAA,iBAAO,EAAC,MAAM,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;QAClD,OAAO,CAAC,IAAI,GAAG,KAAK,CAAA;QACpB,OAAM;IACR,CAAC;IAED,IAAI,UAAU,GAAG,gBAAgB,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,gBAAgB,kBAAkB,CACrG,OAAO,CAAC,UAAU,IAAI,GAAG,CAC1B,EAAE,CAAA;IAEH,IAAA,0CAAoB,EAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAEpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;AAC9B,CAAC,CAAC,CAAA","sourcesContent":["import Router from 'koa-router'\n\nimport { config } from '@things-factory/env'\nimport { signinMiddleware } from '../middlewares'\nimport { accepts } from '../utils/accepts'\nimport { setAccessTokenCookie } from '../utils/access-token-cookie'\n\nconst disableUserSignupProcess = config.get('disableUserSignupProcess', false)\nconst disableUserFavoredLanguage = config.get('i18n/disableUserFavoredLanguage', false)\nconst languages = config.get('i18n/languages', false)\n\nconst SSOConfig = config.get('sso', {} as any)\nconst SSOLinks = Object.values(SSOConfig)\n .filter(({ link, title }) => link && title)\n .map(({ link, title }) => {\n return { link, title }\n })\n\nexport const authSigninRouter = new Router()\n\nauthSigninRouter.get('/auth/signin', async (context, next) => {\n const { redirect_to, username } = context.query\n\n await context.render('auth-page', {\n pageElement: 'auth-signin',\n elementScript: '/auth/signin.js',\n data: {\n username,\n redirectTo: redirect_to,\n ssoLinks: SSOLinks,\n disableUserSignupProcess,\n disableUserFavoredLanguage,\n languages\n }\n })\n})\n\nauthSigninRouter.post('/auth/signin', signinMiddleware, async (context, next) => {\n const { request, t } = context\n const { token, domain } = context.state\n const { body: reqBody, header } = request\n\n if (!accepts(header.accept, ['text/html', '*/*'])) {\n context.body = token\n return\n }\n\n var redirectTo = `/auth/checkin${domain ? '/' + domain.subdomain : ''}?redirect_to=${encodeURIComponent(\n reqBody.redirectTo || '/'\n )}`\n\n setAccessTokenCookie(context, token)\n\n context.redirect(redirectTo)\n})\n"]}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { User } from '../../service/user/user';
|
1
2
|
import { Invitation } from './invitation';
|
2
3
|
export declare class InvitationMutation {
|
3
4
|
cancelInvitation(email: string, reference: string, type: string): Promise<boolean>;
|
@@ -5,12 +6,12 @@ export declare class InvitationMutation {
|
|
5
6
|
email: string;
|
6
7
|
reference: string;
|
7
8
|
type: string;
|
8
|
-
|
9
|
-
updater: import("..").User;
|
9
|
+
updater: User;
|
10
10
|
id: string;
|
11
11
|
token: string;
|
12
12
|
createdAt: Date;
|
13
13
|
updatedAt: Date;
|
14
|
+
creator: User;
|
14
15
|
creatorId: string;
|
15
16
|
updaterId: string;
|
16
17
|
} & Invitation>;
|
@@ -2,9 +2,11 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.InvitationMutation = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
|
+
const typeorm_1 = require("typeorm");
|
5
6
|
const type_graphql_1 = require("type-graphql");
|
6
7
|
const graphql_scalars_1 = require("graphql-scalars");
|
7
8
|
const shell_1 = require("@things-factory/shell");
|
9
|
+
const user_1 = require("../../service/user/user");
|
8
10
|
const invitation_1 = require("../../controllers/invitation");
|
9
11
|
const invitation_2 = require("./invitation");
|
10
12
|
let InvitationMutation = class InvitationMutation {
|
@@ -18,26 +20,36 @@ let InvitationMutation = class InvitationMutation {
|
|
18
20
|
return true;
|
19
21
|
}
|
20
22
|
async sendInvitation(email, reference, type, context) {
|
21
|
-
const
|
22
|
-
const
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
const { user: updater } = context.state;
|
24
|
+
const invitationRepository = (0, shell_1.getRepository)(invitation_2.Invitation);
|
25
|
+
var user = await (0, shell_1.getRepository)(user_1.User).findOne({
|
26
|
+
where: {
|
27
|
+
email: (0, typeorm_1.ILike)(email),
|
28
|
+
status: user_1.UserStatus.ACTIVATED
|
29
|
+
}
|
26
30
|
});
|
27
|
-
|
31
|
+
if (!user) {
|
32
|
+
throw new Error(`user not found: ${email}`);
|
33
|
+
}
|
28
34
|
await (0, invitation_1.sendInvitationEmail)({
|
29
35
|
invitation: {
|
30
36
|
email,
|
31
37
|
reference,
|
32
38
|
type
|
33
39
|
},
|
40
|
+
user,
|
34
41
|
context
|
35
42
|
});
|
43
|
+
const oldone = await invitationRepository.findOneBy({
|
44
|
+
email,
|
45
|
+
type,
|
46
|
+
reference
|
47
|
+
});
|
36
48
|
// update or create
|
37
|
-
return await
|
49
|
+
return await invitationRepository.save(Object.assign(Object.assign({ creator: updater }, oldone), { // take only id from oldone for update
|
38
50
|
email,
|
39
51
|
reference,
|
40
|
-
type,
|
52
|
+
type, updater: updater }));
|
41
53
|
}
|
42
54
|
};
|
43
55
|
exports.InvitationMutation = InvitationMutation;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"invitation-mutation.js","sourceRoot":"","sources":["../../../server/service/invitation/invitation-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAA2D;AAC3D,qDAAqD;AAErD,iDAAqD;AAErD,6DAAkE;AAClE,6CAAyC;AAGlC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAEvB,AAAN,KAAK,CAAC,gBAAgB,CACuB,KAAa,EACtC,SAAiB,EACtB,IAAY;QAEzB,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,uBAAU,CAAC,CAAA;QAE5C,MAAM,UAAU,CAAC,MAAM,CAAC;YACtB,KAAK;YACL,SAAS;YACT,IAAI;SACL,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;IAGK,AAAN,KAAK,CAAC,cAAc,CACyB,KAAa,EACtC,SAAiB,EACtB,IAAY,EAClB,OAAwB;QAE/B,MAAM,
|
1
|
+
{"version":3,"file":"invitation-mutation.js","sourceRoot":"","sources":["../../../server/service/invitation/invitation-mutation.ts"],"names":[],"mappings":";;;;AAAA,qCAA+B;AAE/B,+CAA2D;AAC3D,qDAAqD;AAErD,iDAAqD;AAErD,kDAA0D;AAC1D,6DAAkE;AAClE,6CAAyC;AAGlC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAEvB,AAAN,KAAK,CAAC,gBAAgB,CACuB,KAAa,EACtC,SAAiB,EACtB,IAAY;QAEzB,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,uBAAU,CAAC,CAAA;QAE5C,MAAM,UAAU,CAAC,MAAM,CAAC;YACtB,KAAK;YACL,SAAS;YACT,IAAI;SACL,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;IAGK,AAAN,KAAK,CAAC,cAAc,CACyB,KAAa,EACtC,SAAiB,EACtB,IAAY,EAClB,OAAwB;QAE/B,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QACvC,MAAM,oBAAoB,GAAG,IAAA,qBAAa,EAAC,uBAAU,CAAC,CAAA;QAEtD,IAAI,IAAI,GAAG,MAAM,IAAA,qBAAa,EAAC,WAAI,CAAC,CAAC,OAAO,CAAC;YAC3C,KAAK,EAAE;gBACL,KAAK,EAAE,IAAA,eAAK,EAAC,KAAK,CAAC;gBACnB,MAAM,EAAE,iBAAU,CAAC,SAAS;aAC7B;SACF,CAAC,CAAA;QAEF,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,mBAAmB,KAAK,EAAE,CAAC,CAAA;QAC7C,CAAC;QAED,MAAM,IAAA,gCAAmB,EAAC;YACxB,UAAU,EAAE;gBACV,KAAK;gBACL,SAAS;gBACT,IAAI;aACL;YACD,IAAI;YACJ,OAAO;SACR,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,SAAS,CAAC;YAClD,KAAK;YACL,IAAI;YACJ,SAAS;SACV,CAAC,CAAA;QAEF,mBAAmB;QACnB,OAAO,MAAM,oBAAoB,CAAC,IAAI,+BACpC,OAAO,EAAE,OAAO,IACb,MAAM,KAAE,sCAAsC;YACjD,KAAK;YACL,SAAS;YACT,IAAI,EACJ,OAAO,EAAE,OAAO,IAChB,CAAA;IACJ,CAAC;CACF,CAAA;AAjEY,gDAAkB;AAEvB;IADL,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC;IAE1B,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,qCAAmB,CAAC,CAAA;IACzC,mBAAA,IAAA,kBAAG,EAAC,WAAW,CAAC,CAAA;IAChB,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;;;;0DAWb;AAGK;IADL,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,uBAAU,CAAC;IAE7B,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,qCAAmB,CAAC,CAAA;IACzC,mBAAA,IAAA,kBAAG,EAAC,WAAW,CAAC,CAAA;IAChB,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IACX,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;wDAyCP;6BAhEU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,uBAAU,CAAC;GACR,kBAAkB,CAiE9B","sourcesContent":["import { ILike } from 'typeorm'\n\nimport { Arg, Ctx, Mutation, Resolver } from 'type-graphql'\nimport { GraphQLEmailAddress } from 'graphql-scalars'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { User, UserStatus } from '../../service/user/user'\nimport { sendInvitationEmail } from '../../controllers/invitation'\nimport { Invitation } from './invitation'\n\n@Resolver(Invitation)\nexport class InvitationMutation {\n @Mutation(returns => Boolean)\n async cancelInvitation(\n @Arg('email', type => GraphQLEmailAddress) email: string,\n @Arg('reference') reference: string,\n @Arg('type') type: string\n ) {\n const repository = getRepository(Invitation)\n\n await repository.delete({\n email,\n reference,\n type\n })\n\n return true\n }\n\n @Mutation(returns => Invitation)\n async sendInvitation(\n @Arg('email', type => GraphQLEmailAddress) email: string,\n @Arg('reference') reference: string,\n @Arg('type') type: string,\n @Ctx() context: ResolverContext\n ) {\n const { user: updater } = context.state\n const invitationRepository = getRepository(Invitation)\n\n var user = await getRepository(User).findOne({\n where: {\n email: ILike(email),\n status: UserStatus.ACTIVATED\n }\n })\n\n if (!user) {\n throw new Error(`user not found: ${email}`)\n }\n\n await sendInvitationEmail({\n invitation: {\n email,\n reference,\n type\n },\n user,\n context\n })\n\n const oldone = await invitationRepository.findOneBy({\n email,\n type,\n reference\n })\n\n // update or create\n return await invitationRepository.save({\n creator: updater,\n ...oldone, // take only id from oldone for update\n email,\n reference,\n type,\n updater: updater\n })\n }\n}\n"]}
|
@@ -9,6 +9,7 @@ export declare class UserMutation {
|
|
9
9
|
salt: string;
|
10
10
|
passwordUpdatedAt: Date;
|
11
11
|
password: string;
|
12
|
+
username: string;
|
12
13
|
name: string;
|
13
14
|
description?: string;
|
14
15
|
email: string;
|
@@ -18,13 +19,13 @@ export declare class UserMutation {
|
|
18
19
|
} & User>;
|
19
20
|
updateUser(email: string, patch: UserPatch, context: ResolverContext): Promise<any>;
|
20
21
|
updateMultipleUser(patches: UserPatch[], context: ResolverContext): Promise<any[]>;
|
21
|
-
deleteUser(
|
22
|
-
deleteUsers(
|
23
|
-
inviteUser(
|
24
|
-
deleteDomainUser(
|
25
|
-
transferOwner(
|
26
|
-
activateUser(
|
27
|
-
inactivateUser(
|
28
|
-
resetPasswordToDefault(
|
29
|
-
updateUserRoles(
|
22
|
+
deleteUser(username: string, context: ResolverContext): Promise<boolean>;
|
23
|
+
deleteUsers(usernames: string[], context: ResolverContext): Promise<boolean>;
|
24
|
+
inviteUser(username: string, context: ResolverContext): Promise<boolean>;
|
25
|
+
deleteDomainUser(username: string, context: ResolverContext): Promise<boolean>;
|
26
|
+
transferOwner(username: string, context: ResolverContext): Promise<boolean>;
|
27
|
+
activateUser(username: string, context: ResolverContext): Promise<boolean>;
|
28
|
+
inactivateUser(username: string, context: ResolverContext): Promise<boolean>;
|
29
|
+
resetPasswordToDefault(username: string, context: ResolverContext): Promise<boolean>;
|
30
|
+
updateUserRoles(username: string, availableRoles: ObjectRef[], selectedRoles: ObjectRef[], context: ResolverContext): Promise<User>;
|
30
31
|
}
|
@@ -12,24 +12,33 @@ const get_domain_users_1 = require("../../utils/get-domain-users");
|
|
12
12
|
const role_1 = require("../role/role");
|
13
13
|
const user_1 = require("./user");
|
14
14
|
const user_types_1 = require("./user-types");
|
15
|
+
const error_code_1 = require("../../constants/error-code");
|
15
16
|
let UserMutation = class UserMutation {
|
16
17
|
async createUser(user, context) {
|
17
18
|
const { domain, tx } = context.state;
|
18
19
|
const { defaultPassword } = env_1.config.get('password');
|
19
|
-
const { email } = user;
|
20
|
+
const { username, email } = user;
|
21
|
+
const userRepository = (0, shell_1.getRepository)(user_1.User, tx);
|
22
|
+
user.username = username.trim();
|
20
23
|
user.email = email.trim();
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
if (await userRepository.findOne({ where: { username: user.username } })) {
|
25
|
+
throw new Error(context.t(error_code_1.USERNAME_ALREADY_EXISTS));
|
26
|
+
}
|
27
|
+
if (await userRepository.findOne({ where: { email: (0, typeorm_1.ILike)(user.email) } })) {
|
28
|
+
throw new Error(context.t(error_code_1.EMAIL_ALREADY_EXISTS));
|
24
29
|
}
|
25
30
|
if (!user.password && !defaultPassword) {
|
26
|
-
throw new Error(
|
31
|
+
throw new Error('initial password or default password should be supported.');
|
32
|
+
}
|
33
|
+
// TODO username은 다음 패턴을 따라야 한다. pattern="^[A-Za-z0-9]*$"
|
34
|
+
if (!/^[A-Za-z0-9]*$/.test(user.username)) {
|
35
|
+
throw new Error(context.t('error.invalid x', { x: context.t('field.username') }));
|
27
36
|
}
|
28
37
|
// consider if validation password rule is required
|
29
38
|
/* check if password is following the rule */
|
30
39
|
// User.validatePasswordByRule(user.password, context.lng)
|
31
40
|
const salt = user_1.User.generateSalt();
|
32
|
-
return await
|
41
|
+
return await userRepository.save(Object.assign(Object.assign({ creator: context.state.user, updater: context.state.user }, user), { domains: [domain], roles: user.roles && user.roles.length
|
33
42
|
? await (0, shell_1.getRepository)(role_1.Role, tx).findBy({
|
34
43
|
id: (0, typeorm_1.In)(user.roles.map(role => role.id)),
|
35
44
|
domain: { id: domain.id }
|
@@ -115,22 +124,29 @@ let UserMutation = class UserMutation {
|
|
115
124
|
}
|
116
125
|
return results;
|
117
126
|
}
|
118
|
-
async deleteUser(
|
127
|
+
async deleteUser(username, context) {
|
119
128
|
const { tx } = context.state;
|
120
|
-
await (0, delete_user_1.deleteUser)({
|
129
|
+
await (0, delete_user_1.deleteUser)({ username }, tx);
|
121
130
|
return true;
|
122
131
|
}
|
123
|
-
async deleteUsers(
|
132
|
+
async deleteUsers(usernames, context) {
|
124
133
|
const { tx } = context.state;
|
125
|
-
await (0, delete_user_1.deleteUsers)({
|
134
|
+
await (0, delete_user_1.deleteUsers)({ usernames }, tx);
|
126
135
|
return true;
|
127
136
|
}
|
128
|
-
async inviteUser(
|
137
|
+
async inviteUser(username, context) {
|
129
138
|
const { domain, tx } = context.state;
|
130
|
-
const
|
131
|
-
|
139
|
+
const userRepository = (0, shell_1.getRepository)(user_1.User, tx);
|
140
|
+
var invitee = await userRepository.findOne({
|
141
|
+
where: { username },
|
132
142
|
relations: ['domains']
|
133
143
|
});
|
144
|
+
if (!invitee && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(username)) {
|
145
|
+
invitee = await userRepository.findOne({
|
146
|
+
where: { email: (0, typeorm_1.ILike)(username) },
|
147
|
+
relations: ['domains']
|
148
|
+
});
|
149
|
+
}
|
134
150
|
if (!invitee) {
|
135
151
|
throw new Error(context.t('error.failed to find x', { x: context.t('field.user') }));
|
136
152
|
}
|
@@ -139,15 +155,22 @@ let UserMutation = class UserMutation {
|
|
139
155
|
throw new Error(context.t('error.x already exists in y', { x: context.t('field.user'), y: domain.name }));
|
140
156
|
}
|
141
157
|
invitee.domains = [...existingDomains, domain];
|
142
|
-
await
|
158
|
+
await userRepository.save(invitee);
|
143
159
|
return true;
|
144
160
|
}
|
145
|
-
async deleteDomainUser(
|
161
|
+
async deleteDomainUser(username, context) {
|
146
162
|
const { tx, domain } = context.state;
|
147
|
-
|
148
|
-
|
149
|
-
|
163
|
+
const userRepository = (0, shell_1.getRepository)(user_1.User, tx);
|
164
|
+
var user = await userRepository.findOne({
|
165
|
+
where: { username },
|
166
|
+
relations: ['domains', 'roles']
|
150
167
|
});
|
168
|
+
if (!user && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(username)) {
|
169
|
+
user = await userRepository.findOne({
|
170
|
+
where: { email: (0, typeorm_1.ILike)(username) },
|
171
|
+
relations: ['domains', 'roles']
|
172
|
+
});
|
173
|
+
}
|
151
174
|
if (!user) {
|
152
175
|
throw new Error(context.t('error.failed to find x', { x: context.t('field.user') }));
|
153
176
|
}
|
@@ -158,18 +181,25 @@ let UserMutation = class UserMutation {
|
|
158
181
|
// Remove domain relation with user
|
159
182
|
user.domains.splice(targetDomainIdx, 1);
|
160
183
|
// Remove domain's roles that user has
|
161
|
-
user.roles = user.roles.filter((role) => role.
|
162
|
-
await
|
184
|
+
user.roles = user.roles.filter((role) => role.domainId !== domain.id);
|
185
|
+
await userRepository.save(user);
|
163
186
|
return true;
|
164
187
|
}
|
165
|
-
async transferOwner(
|
188
|
+
async transferOwner(username, context) {
|
166
189
|
const { domain, tx } = context.state;
|
167
|
-
const
|
168
|
-
|
169
|
-
|
190
|
+
const userRepository = (0, shell_1.getRepository)(user_1.User, tx);
|
191
|
+
var user = await userRepository.findOne({
|
192
|
+
where: { username },
|
193
|
+
relations: ['domains']
|
170
194
|
});
|
195
|
+
if (!user && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(username)) {
|
196
|
+
user = await userRepository.findOne({
|
197
|
+
where: { email: (0, typeorm_1.ILike)(username) },
|
198
|
+
relations: ['domains']
|
199
|
+
});
|
200
|
+
}
|
171
201
|
if (!user) {
|
172
|
-
throw new Error('
|
202
|
+
throw new Error(context.t('error.failed to find x', { x: context.t('field.user') }));
|
173
203
|
}
|
174
204
|
if (user.status !== user_1.UserStatus.ACTIVATED) {
|
175
205
|
throw new Error('Only activated users are eligible to receive admin privileges.');
|
@@ -184,33 +214,47 @@ let UserMutation = class UserMutation {
|
|
184
214
|
await (0, shell_1.getRepository)(shell_1.Domain, tx).save(domain);
|
185
215
|
return true;
|
186
216
|
}
|
187
|
-
async activateUser(
|
217
|
+
async activateUser(username, context) {
|
188
218
|
var _a;
|
189
219
|
const { tx, domain } = context.state;
|
190
|
-
const
|
191
|
-
|
220
|
+
const userRepository = (0, shell_1.getRepository)(user_1.User, tx);
|
221
|
+
var targetUser = await userRepository.findOne({
|
222
|
+
where: { username },
|
192
223
|
relations: ['domains']
|
193
224
|
});
|
225
|
+
if (!targetUser && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(username)) {
|
226
|
+
targetUser = await userRepository.findOne({
|
227
|
+
where: { email: (0, typeorm_1.ILike)(username) },
|
228
|
+
relations: ['domains']
|
229
|
+
});
|
230
|
+
}
|
194
231
|
if (!targetUser) {
|
195
|
-
throw new Error('
|
232
|
+
throw new Error(context.t('error.failed to find x', { x: context.t('field.user') }));
|
196
233
|
}
|
197
234
|
if (!((_a = targetUser === null || targetUser === void 0 ? void 0 : targetUser.domains) === null || _a === void 0 ? void 0 : _a.find((userDomain) => userDomain.id === domain.id))) {
|
198
235
|
throw new Error('User is not belong to domain');
|
199
236
|
}
|
200
237
|
targetUser.failCount = 0;
|
201
238
|
targetUser.status = user_1.UserStatus.ACTIVATED;
|
202
|
-
await
|
239
|
+
await userRepository.save(targetUser);
|
203
240
|
return true;
|
204
241
|
}
|
205
|
-
async inactivateUser(
|
242
|
+
async inactivateUser(username, context) {
|
206
243
|
var _a;
|
207
244
|
const { tx, domain } = context.state;
|
208
|
-
const
|
209
|
-
|
245
|
+
const userRepository = (0, shell_1.getRepository)(user_1.User, tx);
|
246
|
+
var targetUser = await userRepository.findOne({
|
247
|
+
where: { username },
|
210
248
|
relations: ['domains']
|
211
249
|
});
|
250
|
+
if (!targetUser && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(username)) {
|
251
|
+
targetUser = await userRepository.findOne({
|
252
|
+
where: { email: (0, typeorm_1.ILike)(username) },
|
253
|
+
relations: ['domains']
|
254
|
+
});
|
255
|
+
}
|
212
256
|
if (!targetUser) {
|
213
|
-
throw new Error('
|
257
|
+
throw new Error(context.t('error.failed to find x', { x: context.t('field.user') }));
|
214
258
|
}
|
215
259
|
if (!((_a = targetUser === null || targetUser === void 0 ? void 0 : targetUser.domains) === null || _a === void 0 ? void 0 : _a.find((userDomain) => userDomain.id === domain.id))) {
|
216
260
|
throw new Error('User is not belong to domain');
|
@@ -219,39 +263,53 @@ let UserMutation = class UserMutation {
|
|
219
263
|
throw new Error('Admin deactivation not allowed');
|
220
264
|
}
|
221
265
|
targetUser.status = user_1.UserStatus.INACTIVE;
|
222
|
-
await
|
266
|
+
await userRepository.save(targetUser);
|
223
267
|
return true;
|
224
268
|
}
|
225
|
-
async resetPasswordToDefault(
|
269
|
+
async resetPasswordToDefault(username, context) {
|
226
270
|
var _a;
|
227
271
|
const { tx, domain } = context.state;
|
228
272
|
const { defaultPassword } = env_1.config.get('password');
|
229
273
|
if (!defaultPassword) {
|
230
274
|
throw new Error('No default password found');
|
231
275
|
}
|
232
|
-
const
|
233
|
-
|
276
|
+
const userRepository = (0, shell_1.getRepository)(user_1.User, tx);
|
277
|
+
var targetUser = await userRepository.findOne({
|
278
|
+
where: { username },
|
234
279
|
relations: ['domains']
|
235
280
|
});
|
281
|
+
if (!targetUser && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(username)) {
|
282
|
+
targetUser = await userRepository.findOne({
|
283
|
+
where: { email: (0, typeorm_1.ILike)(username) },
|
284
|
+
relations: ['domains']
|
285
|
+
});
|
286
|
+
}
|
236
287
|
if (!targetUser) {
|
237
|
-
throw new Error('
|
288
|
+
throw new Error(context.t('error.failed to find x', { x: context.t('field.user') }));
|
238
289
|
}
|
239
290
|
if (!((_a = targetUser === null || targetUser === void 0 ? void 0 : targetUser.domains) === null || _a === void 0 ? void 0 : _a.find((userDomain) => userDomain.id === domain.id))) {
|
240
291
|
throw new Error('User is not belong to domain');
|
241
292
|
}
|
242
293
|
targetUser.salt = user_1.User.generateSalt();
|
243
294
|
targetUser.password = user_1.User.encode(defaultPassword, targetUser.salt);
|
244
|
-
await
|
295
|
+
await userRepository.save(targetUser);
|
245
296
|
return true;
|
246
297
|
}
|
247
|
-
async updateUserRoles(
|
298
|
+
async updateUserRoles(username, availableRoles, selectedRoles, context) {
|
248
299
|
const { domain, tx } = context.state;
|
249
|
-
|
250
|
-
|
300
|
+
const userRepository = (0, shell_1.getRepository)(user_1.User, tx);
|
301
|
+
var user = await userRepository.findOne({
|
302
|
+
where: { username },
|
251
303
|
relations: ['domains', 'roles']
|
252
304
|
});
|
305
|
+
if (!user && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(username)) {
|
306
|
+
user = await userRepository.findOne({
|
307
|
+
where: { email: (0, typeorm_1.ILike)(username) },
|
308
|
+
relations: ['domains', 'roles']
|
309
|
+
});
|
310
|
+
}
|
253
311
|
if (!user) {
|
254
|
-
throw new Error('
|
312
|
+
throw new Error(context.t('error.failed to find x', { x: context.t('field.user') }));
|
255
313
|
}
|
256
314
|
if (user.domains.map((d) => d.id).indexOf(domain.id) < 0) {
|
257
315
|
throw new Error(`User is not belongs to current domain`);
|
@@ -259,7 +317,7 @@ let UserMutation = class UserMutation {
|
|
259
317
|
const availableRoleIds = availableRoles.map((r) => r.id);
|
260
318
|
user.roles = user.roles.filter((r) => availableRoleIds.indexOf(r.id) < 0);
|
261
319
|
user.roles = user.roles.concat(selectedRoles);
|
262
|
-
return await
|
320
|
+
return await userRepository.save(user);
|
263
321
|
}
|
264
322
|
};
|
265
323
|
exports.UserMutation = UserMutation;
|
@@ -298,7 +356,7 @@ tslib_1.__decorate([
|
|
298
356
|
(0, type_graphql_1.Directive)('@privilege(category: "user", privilege: "mutation", domainOwnerGranted: true)'),
|
299
357
|
(0, type_graphql_1.Directive)('@transaction'),
|
300
358
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete a user' }),
|
301
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('
|
359
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('username')),
|
302
360
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
303
361
|
tslib_1.__metadata("design:type", Function),
|
304
362
|
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
@@ -308,7 +366,7 @@ tslib_1.__decorate([
|
|
308
366
|
(0, type_graphql_1.Directive)('@privilege(category: "user", privilege: "mutation", domainOwnerGranted: true)'),
|
309
367
|
(0, type_graphql_1.Directive)('@transaction'),
|
310
368
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete some users' }),
|
311
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('
|
369
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('usernames', type => [String])),
|
312
370
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
313
371
|
tslib_1.__metadata("design:type", Function),
|
314
372
|
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
@@ -317,7 +375,7 @@ tslib_1.__decorate([
|
|
317
375
|
tslib_1.__decorate([
|
318
376
|
(0, type_graphql_1.Directive)('@transaction'),
|
319
377
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To invite new user' }),
|
320
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('
|
378
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('username')),
|
321
379
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
322
380
|
tslib_1.__metadata("design:type", Function),
|
323
381
|
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
@@ -327,7 +385,7 @@ tslib_1.__decorate([
|
|
327
385
|
(0, type_graphql_1.Directive)('@transaction'),
|
328
386
|
(0, type_graphql_1.Directive)('@privilege(category: "user", privilege: "mutation", domainOwnerGranted: true)'),
|
329
387
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete domain user' }),
|
330
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('
|
388
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('username')),
|
331
389
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
332
390
|
tslib_1.__metadata("design:type", Function),
|
333
391
|
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
@@ -337,7 +395,7 @@ tslib_1.__decorate([
|
|
337
395
|
(0, type_graphql_1.Directive)('@privilege(domainOwnerGranted: true, superUserGranted: true)'),
|
338
396
|
(0, type_graphql_1.Directive)('@transaction'),
|
339
397
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To transfer owner of domain' }),
|
340
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('
|
398
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('username')),
|
341
399
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
342
400
|
tslib_1.__metadata("design:type", Function),
|
343
401
|
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
@@ -347,7 +405,7 @@ tslib_1.__decorate([
|
|
347
405
|
(0, type_graphql_1.Directive)('@privilege(category: "user", privilege: "mutation", domainOwnerGranted: true)'),
|
348
406
|
(0, type_graphql_1.Directive)('@transaction'),
|
349
407
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To activate user' }),
|
350
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('
|
408
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('username')),
|
351
409
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
352
410
|
tslib_1.__metadata("design:type", Function),
|
353
411
|
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
@@ -357,7 +415,7 @@ tslib_1.__decorate([
|
|
357
415
|
(0, type_graphql_1.Directive)('@privilege(category: "user", privilege: "mutation", domainOwnerGranted: true)'),
|
358
416
|
(0, type_graphql_1.Directive)('@transaction'),
|
359
417
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To inactivate user' }),
|
360
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('
|
418
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('username')),
|
361
419
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
362
420
|
tslib_1.__metadata("design:type", Function),
|
363
421
|
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
@@ -367,7 +425,7 @@ tslib_1.__decorate([
|
|
367
425
|
(0, type_graphql_1.Directive)('@privilege(category: "user", privilege: "mutation", domainOwnerGranted: true)'),
|
368
426
|
(0, type_graphql_1.Directive)('@transaction'),
|
369
427
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To reset password to default' }),
|
370
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('
|
428
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('username')),
|
371
429
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
372
430
|
tslib_1.__metadata("design:type", Function),
|
373
431
|
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
@@ -377,7 +435,7 @@ tslib_1.__decorate([
|
|
377
435
|
(0, type_graphql_1.Directive)('@privilege(category: "user", privilege: "mutation", domainOwnerGranted: true)'),
|
378
436
|
(0, type_graphql_1.Directive)('@transaction'),
|
379
437
|
(0, type_graphql_1.Mutation)(returns => user_1.User, { description: 'To update roles for a user' }),
|
380
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('
|
438
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('username')),
|
381
439
|
tslib_1.__param(1, (0, type_graphql_1.Arg)('availableRoles', type => [shell_1.ObjectRef])),
|
382
440
|
tslib_1.__param(2, (0, type_graphql_1.Arg)('selectedRoles', type => [shell_1.ObjectRef])),
|
383
441
|
tslib_1.__param(3, (0, type_graphql_1.Ctx)()),
|