@things-factory/auth-base 5.0.0 → 5.0.11
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/config/config.development.js +2 -1
- package/dist-server/constants/error-code.js.map +1 -1
- package/dist-server/constants/error-message.js.map +1 -1
- package/dist-server/constants/max-age.js.map +1 -1
- package/dist-server/controllers/auth.js +5 -18
- package/dist-server/controllers/auth.js.map +1 -1
- package/dist-server/controllers/change-pwd.js +6 -8
- package/dist-server/controllers/change-pwd.js.map +1 -1
- package/dist-server/controllers/checkin.js.map +1 -1
- package/dist-server/controllers/delete-user.js.map +1 -1
- package/dist-server/controllers/invitation.js +3 -8
- package/dist-server/controllers/invitation.js.map +1 -1
- package/dist-server/controllers/profile.js.map +1 -1
- package/dist-server/controllers/reset-password.js +7 -9
- package/dist-server/controllers/reset-password.js.map +1 -1
- package/dist-server/controllers/signin.js.map +1 -1
- package/dist-server/controllers/signup.js.map +1 -1
- package/dist-server/controllers/unlock-user.js.map +1 -1
- package/dist-server/controllers/utils/make-invitation-token.js +2 -4
- package/dist-server/controllers/utils/make-invitation-token.js.map +1 -1
- package/dist-server/controllers/utils/make-verification-token.js +2 -4
- package/dist-server/controllers/utils/make-verification-token.js.map +1 -1
- package/dist-server/controllers/utils/password-rule.js +2 -5
- package/dist-server/controllers/utils/password-rule.js.map +1 -1
- package/dist-server/controllers/utils/save-invitation-token.js.map +1 -1
- package/dist-server/controllers/utils/save-verification-token.js.map +1 -1
- package/dist-server/controllers/verification.js.map +1 -1
- package/dist-server/errors/auth-error.js +2 -24
- package/dist-server/errors/auth-error.js.map +1 -1
- package/dist-server/errors/index.js +3 -16
- package/dist-server/errors/index.js.map +1 -1
- package/dist-server/errors/user-domain-not-match-error.js.map +1 -1
- package/dist-server/index.js +12 -25
- package/dist-server/index.js.map +1 -1
- package/dist-server/middlewares/authenticate-401-middleware.js +0 -6
- package/dist-server/middlewares/authenticate-401-middleware.js.map +1 -1
- package/dist-server/middlewares/domain-authenticate-middleware.js +2 -5
- package/dist-server/middlewares/domain-authenticate-middleware.js.map +1 -1
- package/dist-server/middlewares/graphql-authenticate-middleware.js +1 -3
- package/dist-server/middlewares/graphql-authenticate-middleware.js.map +1 -1
- package/dist-server/middlewares/index.js +6 -24
- package/dist-server/middlewares/index.js.map +1 -1
- package/dist-server/middlewares/jwt-authenticate-middleware.js +5 -11
- package/dist-server/middlewares/jwt-authenticate-middleware.js.map +1 -1
- package/dist-server/middlewares/signin-middleware.js +2 -6
- package/dist-server/middlewares/signin-middleware.js.map +1 -1
- package/dist-server/migrations/1548206416130-SeedUser.js.map +1 -1
- package/dist-server/migrations/1566805283882-SeedPrivilege.js.map +1 -1
- package/dist-server/migrations/index.js.map +1 -1
- package/dist-server/router/auth-checkin-router.js +3 -8
- package/dist-server/router/auth-checkin-router.js.map +1 -1
- package/dist-server/router/auth-private-process-router.js +15 -20
- package/dist-server/router/auth-private-process-router.js.map +1 -1
- package/dist-server/router/auth-public-process-router.js +4 -22
- package/dist-server/router/auth-public-process-router.js.map +1 -1
- package/dist-server/router/auth-signin-router.js +2 -7
- package/dist-server/router/auth-signin-router.js.map +1 -1
- package/dist-server/router/auth-signup-router.js +3 -8
- package/dist-server/router/auth-signup-router.js.map +1 -1
- package/dist-server/router/index.js +9 -22
- package/dist-server/router/index.js.map +1 -1
- package/dist-server/router/oauth2/index.js +3 -16
- package/dist-server/router/oauth2/index.js.map +1 -1
- package/dist-server/router/oauth2/oauth2-authorize-router.js +2 -9
- package/dist-server/router/oauth2/oauth2-authorize-router.js.map +1 -1
- package/dist-server/router/oauth2/oauth2-router.js +5 -10
- package/dist-server/router/oauth2/oauth2-router.js.map +1 -1
- package/dist-server/router/oauth2/oauth2-server.js +2 -14
- package/dist-server/router/oauth2/oauth2-server.js.map +1 -1
- package/dist-server/router/oauth2/passport-oauth2-client-password.js +3 -5
- package/dist-server/router/oauth2/passport-oauth2-client-password.js.map +1 -1
- package/dist-server/router/oauth2/passport-refresh-token.js +3 -5
- package/dist-server/router/oauth2/passport-refresh-token.js.map +1 -1
- package/dist-server/router/path-base-domain-router.js +2 -6
- package/dist-server/router/path-base-domain-router.js.map +1 -1
- package/dist-server/router/site-root-router.js +4 -13
- package/dist-server/router/site-root-router.js.map +1 -1
- package/dist-server/routes.js +2 -9
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/app-binding/app-binding-mutation.js +10 -23
- package/dist-server/service/app-binding/app-binding-mutation.js.map +1 -1
- package/dist-server/service/app-binding/app-binding-query.js +45 -52
- package/dist-server/service/app-binding/app-binding-query.js.map +1 -1
- package/dist-server/service/app-binding/app-binding-types.js +6 -14
- package/dist-server/service/app-binding/app-binding-types.js.map +1 -1
- package/dist-server/service/app-binding/app-binding.js +8 -16
- package/dist-server/service/app-binding/app-binding.js.map +1 -1
- package/dist-server/service/app-binding/index.js.map +1 -1
- package/dist-server/service/appliance/appliance-mutation.js +27 -41
- package/dist-server/service/appliance/appliance-mutation.js.map +1 -1
- package/dist-server/service/appliance/appliance-query.js +29 -40
- package/dist-server/service/appliance/appliance-query.js.map +1 -1
- package/dist-server/service/appliance/appliance-types.js +34 -42
- package/dist-server/service/appliance/appliance-types.js.map +1 -1
- package/dist-server/service/appliance/appliance.js +35 -46
- package/dist-server/service/appliance/appliance.js.map +1 -1
- package/dist-server/service/appliance/index.js.map +1 -1
- package/dist-server/service/application/application-mutation.js +34 -48
- package/dist-server/service/application/application-mutation.js.map +1 -1
- package/dist-server/service/application/application-query.js +44 -55
- package/dist-server/service/application/application-query.js.map +1 -1
- package/dist-server/service/application/application-types.js +41 -49
- package/dist-server/service/application/application-types.js.map +1 -1
- package/dist-server/service/application/application.js +42 -53
- package/dist-server/service/application/application.js.map +1 -1
- package/dist-server/service/application/index.js.map +1 -1
- package/dist-server/service/domain-generator/domain-generator-mutation.js +14 -25
- package/dist-server/service/domain-generator/domain-generator-mutation.js.map +1 -1
- package/dist-server/service/domain-generator/domain-generator-types.js +26 -34
- package/dist-server/service/domain-generator/domain-generator-types.js.map +1 -1
- package/dist-server/service/domain-generator/index.js.map +1 -1
- package/dist-server/service/granted-role/granted-role-mutation.js +9 -20
- package/dist-server/service/granted-role/granted-role-mutation.js.map +1 -1
- package/dist-server/service/granted-role/granted-role-query.js +23 -34
- package/dist-server/service/granted-role/granted-role-query.js.map +1 -1
- package/dist-server/service/granted-role/granted-role.js +12 -20
- package/dist-server/service/granted-role/granted-role.js.map +1 -1
- package/dist-server/service/granted-role/index.js.map +1 -1
- package/dist-server/service/index.js +22 -35
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/invitation/index.js.map +1 -1
- package/dist-server/service/invitation/invitation-mutation.js +17 -28
- package/dist-server/service/invitation/invitation-mutation.js.map +1 -1
- package/dist-server/service/invitation/invitation-query.js +15 -26
- package/dist-server/service/invitation/invitation-query.js.map +1 -1
- package/dist-server/service/invitation/invitation-types.js +6 -14
- package/dist-server/service/invitation/invitation-types.js.map +1 -1
- package/dist-server/service/invitation/invitation.js +24 -32
- package/dist-server/service/invitation/invitation.js.map +1 -1
- package/dist-server/service/login-history/index.js.map +1 -1
- package/dist-server/service/login-history/login-history-query.js +18 -29
- package/dist-server/service/login-history/login-history-query.js.map +1 -1
- package/dist-server/service/login-history/login-history.js +16 -24
- package/dist-server/service/login-history/login-history.js.map +1 -1
- package/dist-server/service/partner/index.js.map +1 -1
- package/dist-server/service/partner/partner-mutation.js +14 -25
- package/dist-server/service/partner/partner-mutation.js.map +1 -1
- package/dist-server/service/partner/partner-query.js +44 -55
- package/dist-server/service/partner/partner-query.js.map +1 -1
- package/dist-server/service/partner/partner-types.js +6 -14
- package/dist-server/service/partner/partner-types.js.map +1 -1
- package/dist-server/service/partner/partner.js +24 -32
- package/dist-server/service/partner/partner.js.map +1 -1
- package/dist-server/service/password-history/index.js.map +1 -1
- package/dist-server/service/password-history/password-history.js +6 -14
- package/dist-server/service/password-history/password-history.js.map +1 -1
- package/dist-server/service/privilege/index.js.map +1 -1
- package/dist-server/service/privilege/privilege-directive.js +2 -5
- package/dist-server/service/privilege/privilege-directive.js.map +1 -1
- package/dist-server/service/privilege/privilege-mutation.js +26 -37
- package/dist-server/service/privilege/privilege-mutation.js.map +1 -1
- package/dist-server/service/privilege/privilege-query.js +35 -46
- package/dist-server/service/privilege/privilege-query.js.map +1 -1
- package/dist-server/service/privilege/privilege-types.js +35 -43
- package/dist-server/service/privilege/privilege-types.js.map +1 -1
- package/dist-server/service/privilege/privilege.js +24 -32
- package/dist-server/service/privilege/privilege.js.map +1 -1
- package/dist-server/service/role/index.js.map +1 -1
- package/dist-server/service/role/role-mutation.js +27 -38
- package/dist-server/service/role/role-mutation.js.map +1 -1
- package/dist-server/service/role/role-query.js +70 -77
- package/dist-server/service/role/role-query.js.map +1 -1
- package/dist-server/service/role/role-types.js +48 -56
- package/dist-server/service/role/role-types.js.map +1 -1
- package/dist-server/service/role/role.js +28 -36
- package/dist-server/service/role/role.js.map +1 -1
- package/dist-server/service/user/index.js.map +1 -1
- package/dist-server/service/user/user-mutation.js +65 -76
- package/dist-server/service/user/user-mutation.js.map +1 -1
- package/dist-server/service/user/user-query.js +59 -70
- package/dist-server/service/user/user-query.js.map +1 -1
- package/dist-server/service/user/user-types.js +40 -48
- package/dist-server/service/user/user-types.js.map +1 -1
- package/dist-server/service/user/user.js +46 -57
- package/dist-server/service/user/user.js.map +1 -1
- package/dist-server/service/verification-token/index.js.map +1 -1
- package/dist-server/service/verification-token/verification-token.js +14 -22
- package/dist-server/service/verification-token/verification-token.js.map +1 -1
- package/dist-server/templates/account-unlock-email.js.map +1 -1
- package/dist-server/templates/invitation-email.js.map +1 -1
- package/dist-server/templates/reset-password-email.js.map +1 -1
- package/dist-server/templates/verification-email.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/dist-server/utils/accepts.js.map +1 -1
- package/dist-server/utils/access-token-cookie.js.map +1 -1
- package/dist-server/utils/check-user-belongs-domain.js.map +1 -1
- package/dist-server/utils/get-domain-from-hostname.js.map +1 -1
- package/dist-server/utils/get-domain-users.js.map +1 -1
- package/dist-server/utils/get-secret.js.map +1 -1
- package/dist-server/utils/get-user-domains.js.map +1 -1
- package/package.json +6 -6
- package/server/controllers/change-pwd.ts +10 -13
- package/server/controllers/invitation.ts +5 -10
- package/server/controllers/reset-password.ts +10 -11
- package/server/controllers/utils/password-rule.ts +0 -1
- package/server/middlewares/authenticate-401-middleware.ts +0 -8
- package/server/middlewares/domain-authenticate-middleware.ts +4 -8
- package/server/middlewares/graphql-authenticate-middleware.ts +1 -5
- package/server/middlewares/index.ts +0 -4
- package/server/middlewares/jwt-authenticate-middleware.ts +4 -9
- package/server/middlewares/signin-middleware.ts +6 -5
- package/server/router/auth-checkin-router.ts +4 -6
- package/server/router/auth-private-process-router.ts +16 -17
- package/server/router/auth-public-process-router.ts +4 -34
- package/server/router/auth-signin-router.ts +1 -5
- package/server/router/auth-signup-router.ts +3 -10
- package/server/router/oauth2/oauth2-authorize-router.ts +1 -8
- package/server/router/oauth2/oauth2-router.ts +0 -6
- package/server/router/oauth2/oauth2-server.ts +0 -12
- package/server/router/path-base-domain-router.ts +0 -4
- package/server/router/site-root-router.ts +4 -11
- package/server/routes.ts +8 -13
- package/server/service/app-binding/app-binding-mutation.ts +3 -6
- package/server/service/app-binding/app-binding-query.ts +7 -6
- package/server/service/appliance/appliance-mutation.ts +0 -5
- package/server/service/application/application-mutation.ts +3 -6
- package/server/service/granted-role/granted-role-mutation.ts +1 -1
- package/server/service/privilege/privilege-directive.ts +0 -2
- package/server/service/privilege/privilege-mutation.ts +5 -4
- package/server/service/role/role-query.ts +14 -8
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { getRepository } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
|
|
3
|
+
import { config } from '@things-factory/env'
|
|
4
|
+
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
CONFIRM_PASSWORD_NOT_MATCHED,
|
|
7
7
|
PASSWORD_NOT_MATCHED,
|
|
8
8
|
PASSWORD_USED_PAST,
|
|
9
|
-
|
|
9
|
+
USER_NOT_FOUND
|
|
10
10
|
} from '../constants/error-code'
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
const debug = require('debug')('things-factory:auth-base:changed-pwd')
|
|
11
|
+
import { AuthError } from '../errors/auth-error'
|
|
12
|
+
import { PasswordHistory } from '../service/password-history/password-history'
|
|
13
|
+
import { User } from '../service/user/user'
|
|
15
14
|
|
|
16
15
|
const HISTORY_SIZE = config.get('password', { history: 0 }).history
|
|
17
16
|
|
|
@@ -55,11 +54,11 @@ export async function changePwd(attrs, currentPass, newPass, confirmPass, contex
|
|
|
55
54
|
try {
|
|
56
55
|
history = JSON.parse(passwordHistory.history)
|
|
57
56
|
if (!(history instanceof Array)) {
|
|
58
|
-
|
|
57
|
+
console.error('password history maybe currupted - not an array')
|
|
59
58
|
history = []
|
|
60
59
|
}
|
|
61
60
|
} catch (e) {
|
|
62
|
-
|
|
61
|
+
console.error('password history currupted - not json format')
|
|
63
62
|
}
|
|
64
63
|
|
|
65
64
|
const found = history.slice(0, HISTORY_SIZE).find(h => {
|
|
@@ -92,8 +91,6 @@ export async function changePwd(attrs, currentPass, newPass, confirmPass, contex
|
|
|
92
91
|
userId: user.id,
|
|
93
92
|
history: JSON.stringify(history)
|
|
94
93
|
})
|
|
95
|
-
|
|
96
|
-
debug('password history updated', history.length)
|
|
97
94
|
}
|
|
98
95
|
|
|
99
96
|
return await user.sign({ subdomain: domain.subdomain })
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Domain } from '@things-factory/shell'
|
|
2
|
-
import { sendEmail } from '@things-factory/email-base'
|
|
3
1
|
import { getRepository } from 'typeorm'
|
|
4
2
|
import { URL } from 'url'
|
|
5
|
-
|
|
3
|
+
|
|
4
|
+
import { sendEmail } from '@things-factory/email-base'
|
|
5
|
+
import { Domain } from '@things-factory/shell'
|
|
6
|
+
|
|
6
7
|
import { Invitation } from '../service/invitation/invitation'
|
|
8
|
+
import { User } from '../service/user/user'
|
|
7
9
|
import { getInvitationEmailForm } from '../templates/invitation-email'
|
|
8
10
|
import { makeInvitationToken } from './utils/make-invitation-token'
|
|
9
11
|
import { saveInvitationToken } from './utils/save-invitation-token'
|
|
10
12
|
|
|
11
|
-
const debug = require('debug')('things-factory:auth-base:invitation')
|
|
12
|
-
|
|
13
13
|
export async function invite(attrs, withEmailInvitation?: Boolean) {
|
|
14
14
|
const { email, reference, type, context } = attrs
|
|
15
15
|
|
|
@@ -17,14 +17,12 @@ export async function invite(attrs, withEmailInvitation?: Boolean) {
|
|
|
17
17
|
var domains = user.domains
|
|
18
18
|
|
|
19
19
|
// TODO reference should not be a domain.id (security reason)
|
|
20
|
-
debug('invite', email, reference, type)
|
|
21
20
|
|
|
22
21
|
if (user) {
|
|
23
22
|
const domain = domains.find(domain => domain.id == reference)
|
|
24
23
|
|
|
25
24
|
if (domain) {
|
|
26
25
|
const msg = `user already a member of the ${type}.`
|
|
27
|
-
debug('invite', msg)
|
|
28
26
|
throw new Error(msg)
|
|
29
27
|
}
|
|
30
28
|
}
|
|
@@ -63,8 +61,6 @@ export async function acceptInvitation(token) {
|
|
|
63
61
|
token
|
|
64
62
|
})
|
|
65
63
|
|
|
66
|
-
debug('accept-invitation', invitation)
|
|
67
|
-
|
|
68
64
|
if (!invitation) {
|
|
69
65
|
throw new Error(`not found invitation.`)
|
|
70
66
|
}
|
|
@@ -79,7 +75,6 @@ export async function acceptInvitation(token) {
|
|
|
79
75
|
|
|
80
76
|
if (domain) {
|
|
81
77
|
const msg = `user already a member of the ${type}.`
|
|
82
|
-
debug('accept-invitation', msg)
|
|
83
78
|
throw new Error(msg)
|
|
84
79
|
}
|
|
85
80
|
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { sendEmail } from '@things-factory/email-base'
|
|
2
1
|
import { getRepository } from 'typeorm'
|
|
3
2
|
import { URL } from 'url'
|
|
4
|
-
|
|
5
|
-
import {
|
|
3
|
+
|
|
4
|
+
import { sendEmail } from '@things-factory/email-base'
|
|
5
|
+
import { config } from '@things-factory/env'
|
|
6
|
+
|
|
7
|
+
import { PASSWORD_USED_PAST } from '../constants/error-code'
|
|
8
|
+
import { AuthError } from '../errors/auth-error'
|
|
6
9
|
import { PasswordHistory } from '../service/password-history/password-history'
|
|
10
|
+
import { User } from '../service/user/user'
|
|
11
|
+
import { VerificationToken, VerificationTokenType } from '../service/verification-token/verification-token'
|
|
7
12
|
import { getResetPasswordEmailForm } from '../templates/reset-password-email'
|
|
8
13
|
import { makeVerificationToken } from './utils/make-verification-token'
|
|
9
14
|
import { saveVerificationToken } from './utils/save-verification-token'
|
|
10
|
-
import { config } from '@things-factory/env'
|
|
11
|
-
import { PASSWORD_USED_PAST } from '../constants/error-code'
|
|
12
|
-
import { AuthError } from '../errors/auth-error'
|
|
13
15
|
|
|
14
16
|
const HISTORY_SIZE = config.get('password', { history: 0 }).history
|
|
15
|
-
const debug = require('debug')('things-factory:auth-base:reset-password')
|
|
16
17
|
|
|
17
18
|
export async function sendPasswordResetEmail({ user, context }) {
|
|
18
19
|
try {
|
|
@@ -78,11 +79,11 @@ export async function resetPassword(token, password, context) {
|
|
|
78
79
|
try {
|
|
79
80
|
history = JSON.parse(passwordHistory.history)
|
|
80
81
|
if (!(history instanceof Array)) {
|
|
81
|
-
|
|
82
|
+
console.error('password history maybe currupted - not an array')
|
|
82
83
|
history = []
|
|
83
84
|
}
|
|
84
85
|
} catch (e) {
|
|
85
|
-
|
|
86
|
+
console.error('password history currupted - not json format')
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
const found = history.slice(0, HISTORY_SIZE).find(h => {
|
|
@@ -121,7 +122,5 @@ export async function resetPassword(token, password, context) {
|
|
|
121
122
|
userId: user.id,
|
|
122
123
|
history: JSON.stringify(history)
|
|
123
124
|
})
|
|
124
|
-
|
|
125
|
-
debug('password history updated', history.length)
|
|
126
125
|
}
|
|
127
126
|
}
|
|
@@ -5,7 +5,6 @@ import { config } from '@things-factory/env'
|
|
|
5
5
|
import { PASSWORD_PATTERN_NOT_MATCHED } from '../../constants/error-code'
|
|
6
6
|
import { AuthError } from '../../errors/auth-error'
|
|
7
7
|
|
|
8
|
-
const debug = require('debug')('things-factory:auth-base:password-rule')
|
|
9
8
|
const passwordConfig = config.get('password') || {
|
|
10
9
|
lowerCase: true,
|
|
11
10
|
upperCase: true,
|
|
@@ -2,8 +2,6 @@ import { SUBDOMAIN_NOTFOUND, USER_LOCKED, USER_NOT_ACTIVATED } from '../constant
|
|
|
2
2
|
import { AuthError } from '../errors/auth-error'
|
|
3
3
|
import { accepts } from '../utils/accepts'
|
|
4
4
|
|
|
5
|
-
const debug = require('debug')('things-factory:auth-base:authenticate-401-middleware')
|
|
6
|
-
|
|
7
5
|
export async function authenticate401Middleware(context, next) {
|
|
8
6
|
try {
|
|
9
7
|
await next()
|
|
@@ -12,7 +10,6 @@ export async function authenticate401Middleware(context, next) {
|
|
|
12
10
|
|
|
13
11
|
if (err instanceof AuthError) {
|
|
14
12
|
message = context.t(`error.${err.errorCode}`, err.detail || {})
|
|
15
|
-
debug(`auth error(${err.errorCode})`, message)
|
|
16
13
|
} else {
|
|
17
14
|
if (err?.status !== 401) {
|
|
18
15
|
throw err
|
|
@@ -21,8 +18,6 @@ export async function authenticate401Middleware(context, next) {
|
|
|
21
18
|
message = err.message
|
|
22
19
|
}
|
|
23
20
|
|
|
24
|
-
debug('401 error', message)
|
|
25
|
-
|
|
26
21
|
context.status = 401
|
|
27
22
|
context.body = message
|
|
28
23
|
|
|
@@ -35,7 +30,6 @@ export async function authenticate401Middleware(context, next) {
|
|
|
35
30
|
const { method, header, path, originalUrl } = context
|
|
36
31
|
|
|
37
32
|
if (method == 'POST' && path.startsWith('/graphql')) {
|
|
38
|
-
debug('Not rewriting', method, path, 'because the graphql request.')
|
|
39
33
|
if (err.errorCode == SUBDOMAIN_NOTFOUND) {
|
|
40
34
|
context.status = 403
|
|
41
35
|
}
|
|
@@ -43,13 +37,11 @@ export async function authenticate401Middleware(context, next) {
|
|
|
43
37
|
}
|
|
44
38
|
|
|
45
39
|
if (!accepts(header.accept, ['text/html', '*/*'])) {
|
|
46
|
-
debug('Not rewriting', method, path, 'because the client does not accept HTML.')
|
|
47
40
|
return
|
|
48
41
|
}
|
|
49
42
|
|
|
50
43
|
const { redirect_to } = context.query
|
|
51
44
|
const { redirectTo = redirect_to || originalUrl } = context.request.body || {}
|
|
52
|
-
debug('rewriting to signin', method, path, message, redirectTo)
|
|
53
45
|
|
|
54
46
|
switch (err.errorCode) {
|
|
55
47
|
case SUBDOMAIN_NOTFOUND:
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { getRepository } from 'typeorm'
|
|
2
|
+
|
|
1
3
|
import { config } from '@things-factory/env'
|
|
2
4
|
import { Domain } from '@things-factory/shell'
|
|
3
|
-
|
|
4
|
-
import { User } from '../service/user/user'
|
|
5
|
+
|
|
5
6
|
import { AuthError } from '../errors/auth-error'
|
|
7
|
+
import { User } from '../service/user/user'
|
|
6
8
|
import { getUserDomains } from '../utils/get-user-domains'
|
|
7
9
|
|
|
8
10
|
const useVirtualHostBasedDomain = !!config.get('useVirtualHostBasedDomain')
|
|
@@ -18,8 +20,6 @@ declare global {
|
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
const debug = require('debug')('things-factory:auth-base:domain-authenticate-middleware')
|
|
22
|
-
|
|
23
23
|
process.domainOwnerGranted = async (domain: Domain, user: User): Promise<boolean> => {
|
|
24
24
|
return domain && domain.owner === user.id
|
|
25
25
|
}
|
|
@@ -51,13 +51,9 @@ export async function domainAuthenticateMiddleware(context: any, next: any) {
|
|
|
51
51
|
|
|
52
52
|
const subdomain: string = domain?.subdomain
|
|
53
53
|
|
|
54
|
-
debug('context - user, subdomain', user?.email, subdomain)
|
|
55
|
-
|
|
56
54
|
// 1. 현재 subdomain 이 결정되지 않은 경우.
|
|
57
55
|
// - checkin로 이동한다.
|
|
58
56
|
if (!subdomain) {
|
|
59
|
-
debug('subdomain not found, move to checkin')
|
|
60
|
-
|
|
61
57
|
throw new AuthError({
|
|
62
58
|
errorCode: AuthError.ERROR_CODES.SUBDOMAIN_NOTFOUND
|
|
63
59
|
})
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { jwtAuthenticateMiddleware } from './jwt-authenticate-middleware'
|
|
2
1
|
import { domainAuthenticateMiddleware } from './domain-authenticate-middleware'
|
|
3
|
-
|
|
4
|
-
const debug = require('debug')('things-factory:auth-base:graphql-authenticate-middleware')
|
|
2
|
+
import { jwtAuthenticateMiddleware } from './jwt-authenticate-middleware'
|
|
5
3
|
|
|
6
4
|
export async function graphqlAuthenticateMiddleware(context, next) {
|
|
7
5
|
const { method, path } = context
|
|
8
6
|
|
|
9
7
|
if (method == 'POST' && path.startsWith('/graphql')) {
|
|
10
|
-
debug(method, path)
|
|
11
|
-
|
|
12
8
|
await jwtAuthenticateMiddleware(context, () => {})
|
|
13
9
|
await domainAuthenticateMiddleware(context, () => {})
|
|
14
10
|
}
|
|
@@ -5,8 +5,6 @@ import { domainAuthenticateMiddleware } from './domain-authenticate-middleware'
|
|
|
5
5
|
import { graphqlAuthenticateMiddleware } from './graphql-authenticate-middleware'
|
|
6
6
|
import { jwtAuthenticateMiddleware } from './jwt-authenticate-middleware'
|
|
7
7
|
|
|
8
|
-
const debug = require('debug')('things-factory:auth-base:middleware')
|
|
9
|
-
|
|
10
8
|
export function initMiddlewares(app: any) {
|
|
11
9
|
/* passport initialize */
|
|
12
10
|
app.use(passport.initialize())
|
|
@@ -22,8 +20,6 @@ export function initMiddlewares(app: any) {
|
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
process.on('bootstrap-module-subscription' as any, (app, subscriptionMiddleware) => {
|
|
25
|
-
debug('bootstrap-module-subscription')
|
|
26
|
-
|
|
27
23
|
subscriptionMiddleware.push(jwtAuthenticateMiddleware, domainAuthenticateMiddleware)
|
|
28
24
|
|
|
29
25
|
// subscriptionMiddleware.push(jwtAuthenticateMiddleware, async (context, next) => {
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import passport from 'passport'
|
|
2
2
|
import { ExtractJwt, Strategy as JWTstrategy } from 'passport-jwt'
|
|
3
|
+
|
|
4
|
+
import { makeVerificationToken } from '../controllers/utils/make-verification-token'
|
|
5
|
+
import { saveVerificationToken } from '../controllers/utils/save-verification-token'
|
|
3
6
|
import { User, UserStatus } from '../service/user/user'
|
|
4
7
|
import { VerificationTokenType } from '../service/verification-token/verification-token'
|
|
8
|
+
import { clearAccessTokenCookie, getAccessTokenCookie } from '../utils/access-token-cookie'
|
|
5
9
|
import { SECRET } from '../utils/get-secret'
|
|
6
|
-
import { getAccessTokenCookie, clearAccessTokenCookie } from '../utils/access-token-cookie'
|
|
7
|
-
import { makeVerificationToken } from '../controllers/utils/make-verification-token'
|
|
8
|
-
import { saveVerificationToken } from '../controllers/utils/save-verification-token'
|
|
9
|
-
|
|
10
|
-
const debug = require('debug')('things-factory:auth-base:jwt-authenticate-middleware')
|
|
11
10
|
|
|
12
11
|
passport.use(
|
|
13
12
|
new JWTstrategy(
|
|
@@ -41,16 +40,12 @@ export async function jwtAuthenticateMiddleware(context, next) {
|
|
|
41
40
|
const { path } = context
|
|
42
41
|
const { user } = context.state
|
|
43
42
|
if (user) {
|
|
44
|
-
debug('reuse user', path, user?.email)
|
|
45
43
|
return await next()
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
return await passport.authenticate('jwt', { session: false }, async (err, decoded, info) => {
|
|
49
|
-
debug('passport.authenticate - jwt', path)
|
|
50
|
-
|
|
51
47
|
if (err || !decoded) {
|
|
52
48
|
const e = (context.state.error = err || info)
|
|
53
|
-
debug('error - jwt', path, err?.message, info?.message)
|
|
54
49
|
|
|
55
50
|
// TODO cookie 가 authenticate에 적용된 상황에서 오류가 발생한 경우만, 쿠키를 클리어한다.
|
|
56
51
|
clearAccessTokenCookie(context)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import passport from 'passport'
|
|
2
2
|
import { Strategy as localStrategy } from 'passport-local'
|
|
3
|
-
import { signin } from '../controllers/signin'
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
import { signin } from '../controllers/signin'
|
|
6
5
|
|
|
7
6
|
passport.use(
|
|
8
7
|
'signin',
|
|
@@ -13,7 +12,11 @@ passport.use(
|
|
|
13
12
|
},
|
|
14
13
|
async (email, password, done) => {
|
|
15
14
|
try {
|
|
16
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
user: userInfo,
|
|
17
|
+
token,
|
|
18
|
+
domains
|
|
19
|
+
} = await signin({
|
|
17
20
|
email,
|
|
18
21
|
password
|
|
19
22
|
})
|
|
@@ -39,8 +42,6 @@ passport.use(
|
|
|
39
42
|
export async function signinMiddleware(context, next) {
|
|
40
43
|
return passport.authenticate('signin', { session: false }, async (err, user, info) => {
|
|
41
44
|
if (err || !user) {
|
|
42
|
-
debug('signin fail', err)
|
|
43
|
-
|
|
44
45
|
throw err
|
|
45
46
|
} else {
|
|
46
47
|
const { user: userInfo, token } = user
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import Router from 'koa-router'
|
|
2
|
+
|
|
1
3
|
import { config } from '@things-factory/env'
|
|
2
|
-
import { accepts } from '../utils/accepts'
|
|
3
4
|
import { Domain, findSubdomainFromPath, getRedirectSubdomainPath } from '@things-factory/shell'
|
|
4
|
-
|
|
5
|
+
|
|
5
6
|
import { LoginHistory } from '../service/login-history/login-history'
|
|
6
7
|
import { User } from '../service/user/user'
|
|
8
|
+
import { accepts } from '../utils/accepts'
|
|
7
9
|
import { clearAccessTokenCookie } from '../utils/access-token-cookie'
|
|
8
10
|
import { getUserDomains } from '../utils/get-user-domains'
|
|
9
11
|
|
|
10
|
-
const debug = require('debug')('things-factory:auth-base:checkin-router')
|
|
11
12
|
const domainType = config.get('domainType')
|
|
12
13
|
|
|
13
14
|
export const authCheckinRouter = new Router()
|
|
@@ -24,7 +25,6 @@ authCheckinRouter.get('/auth/checkin/:subdomain?', async (context, next) => {
|
|
|
24
25
|
if (!accepts(header.accept, ['text/html', '*/*'])) {
|
|
25
26
|
// When request expects non html response
|
|
26
27
|
try {
|
|
27
|
-
debug('get:/auth/checkin/:subdomain?', subdomain)
|
|
28
28
|
if (!subdomain) throw new Error(t('error.domain not specified', { subdomain })) // When params doesn't have subdomain
|
|
29
29
|
const checkInDomain: Domain | undefined = domains.find((d: Domain) => d.subdomain === subdomain) // When no matched domain with subdomain
|
|
30
30
|
if (!checkInDomain) throw new Error(t('error.domain not specified', { subdomain }))
|
|
@@ -42,8 +42,6 @@ authCheckinRouter.get('/auth/checkin/:subdomain?', async (context, next) => {
|
|
|
42
42
|
try {
|
|
43
43
|
let message: string
|
|
44
44
|
|
|
45
|
-
debug('get:/auth/checkin/:subdomain?', subdomain, redirectTo)
|
|
46
|
-
|
|
47
45
|
if (!subdomain) {
|
|
48
46
|
/* try to find domain from redirectTo path */
|
|
49
47
|
subdomain = findSubdomainFromPath(context, redirectTo)
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { config } from '@things-factory/env'
|
|
2
|
-
import { Domain } from '@things-factory/shell'
|
|
3
1
|
import Router from 'koa-router'
|
|
4
|
-
import { getUserDomains } from '../utils/get-user-domains'
|
|
5
2
|
import { getRepository } from 'typeorm'
|
|
3
|
+
|
|
4
|
+
import { config } from '@things-factory/env'
|
|
5
|
+
import { Domain } from '@things-factory/shell'
|
|
6
|
+
|
|
6
7
|
import { changePwd } from '../controllers/change-pwd'
|
|
7
8
|
import { deleteUser } from '../controllers/delete-user'
|
|
8
9
|
import { updateProfile } from '../controllers/profile'
|
|
9
10
|
import { User } from '../service/user/user'
|
|
10
11
|
import { clearAccessTokenCookie, setAccessTokenCookie } from '../utils/access-token-cookie'
|
|
12
|
+
import { getUserDomains } from '../utils/get-user-domains'
|
|
11
13
|
|
|
12
|
-
const debug = require('debug')('things-factory:auth-base:auth-private-process-router')
|
|
13
14
|
const domainType = config.get('domainType')
|
|
14
15
|
|
|
15
16
|
export const authPrivateProcessRouter = new Router({
|
|
@@ -68,18 +69,7 @@ authPrivateProcessRouter
|
|
|
68
69
|
const { domain, user } = context.state
|
|
69
70
|
|
|
70
71
|
let domains: Domain[] = await getUserDomains(user)
|
|
71
|
-
domains = domains
|
|
72
|
-
.filter((d: Domain) => d.extType == domainType)
|
|
73
|
-
.map((d: Domain) => {
|
|
74
|
-
return {
|
|
75
|
-
subdomain: d.subdomain,
|
|
76
|
-
name: d.name,
|
|
77
|
-
description: d.description,
|
|
78
|
-
extType: d.extType,
|
|
79
|
-
brandName: d.brandName,
|
|
80
|
-
brandImage: d.brandImage
|
|
81
|
-
}
|
|
82
|
-
})
|
|
72
|
+
domains = domains.filter((d: Domain) => d.extType == domainType)
|
|
83
73
|
|
|
84
74
|
context.body = {
|
|
85
75
|
user: {
|
|
@@ -89,7 +79,16 @@ authPrivateProcessRouter
|
|
|
89
79
|
owner: await process.domainOwnerGranted(domain, user),
|
|
90
80
|
super: await process.superUserGranted(domain, user)
|
|
91
81
|
},
|
|
92
|
-
domains
|
|
82
|
+
domains: domains.map((d: Domain) => {
|
|
83
|
+
return {
|
|
84
|
+
subdomain: d.subdomain,
|
|
85
|
+
name: d.name,
|
|
86
|
+
description: d.description,
|
|
87
|
+
extType: d.extType,
|
|
88
|
+
brandName: d.brandName,
|
|
89
|
+
brandImage: d.brandImage
|
|
90
|
+
}
|
|
91
|
+
}),
|
|
93
92
|
domain: domain && {
|
|
94
93
|
name: domain.name,
|
|
95
94
|
subdomain: domain.subdomain
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import Router from 'koa-router'
|
|
2
2
|
import { getRepository } from 'typeorm'
|
|
3
|
+
|
|
3
4
|
import { config } from '@things-factory/env'
|
|
4
5
|
import { getSiteRootPath } from '@things-factory/shell'
|
|
6
|
+
|
|
7
|
+
import { resendInvitationEmail } from '../controllers/invitation'
|
|
5
8
|
import { resetPassword, sendPasswordResetEmail } from '../controllers/reset-password'
|
|
6
9
|
import { unlockUser } from '../controllers/unlock-user'
|
|
7
10
|
import { resendVerificationEmail, verify } from '../controllers/verification'
|
|
8
|
-
import { resendInvitationEmail, acceptInvitation } from '../controllers/invitation'
|
|
9
11
|
import { User } from '../service/user/user'
|
|
10
|
-
import { clearAccessTokenCookie } from '../utils/access-token-cookie'
|
|
11
12
|
import { accepts } from '../utils/accepts'
|
|
12
|
-
|
|
13
|
-
const debug = require('debug')('things-factory:auth-base:auth-public-process-router')
|
|
13
|
+
import { clearAccessTokenCookie } from '../utils/access-token-cookie'
|
|
14
14
|
|
|
15
15
|
const passwordRule = config.get('password') || {
|
|
16
16
|
lowerCase: true,
|
|
@@ -31,14 +31,10 @@ export const authPublicProcessRouter = new Router({
|
|
|
31
31
|
authPublicProcessRouter.post('/join', async (context, next) => {
|
|
32
32
|
const { email } = context.request.body || {}
|
|
33
33
|
|
|
34
|
-
debug('post:/join', context.request.body)
|
|
35
|
-
|
|
36
34
|
const user: User = await getRepository(User).findOne({
|
|
37
35
|
email
|
|
38
36
|
})
|
|
39
37
|
|
|
40
|
-
debug('post:/join', email, user?.email)
|
|
41
|
-
|
|
42
38
|
if (user) {
|
|
43
39
|
context.redirect(`/auth/signin?email=${email}`)
|
|
44
40
|
} else {
|
|
@@ -52,8 +48,6 @@ authPublicProcessRouter.all('/signout', async (context, next) => {
|
|
|
52
48
|
|
|
53
49
|
context.body = t('text.signout successfully')
|
|
54
50
|
|
|
55
|
-
debug('all:/signout', header.accept)
|
|
56
|
-
|
|
57
51
|
if (accepts(header.accept, ['text/html', '*/*'])) {
|
|
58
52
|
context.redirect(getSiteRootPath(context))
|
|
59
53
|
}
|
|
@@ -62,8 +56,6 @@ authPublicProcessRouter.all('/signout', async (context, next) => {
|
|
|
62
56
|
authPublicProcessRouter.get('/forgot-password', async (context, next) => {
|
|
63
57
|
const { email } = context.request.query
|
|
64
58
|
|
|
65
|
-
debug('get:/forgot-password', email)
|
|
66
|
-
|
|
67
59
|
await context.render('auth-page', {
|
|
68
60
|
pageElement: 'forgot-password',
|
|
69
61
|
elementScript: '/auth/forgot-password.js',
|
|
@@ -76,8 +68,6 @@ authPublicProcessRouter.get('/forgot-password', async (context, next) => {
|
|
|
76
68
|
authPublicProcessRouter.get('/reset-password', async (context, next) => {
|
|
77
69
|
const { token } = context.request.query
|
|
78
70
|
|
|
79
|
-
debug('get:/reset-password', token)
|
|
80
|
-
|
|
81
71
|
await context.render('auth-page', {
|
|
82
72
|
pageElement: 'reset-password',
|
|
83
73
|
elementScript: '/auth/reset-password.js',
|
|
@@ -91,8 +81,6 @@ authPublicProcessRouter.get('/reset-password', async (context, next) => {
|
|
|
91
81
|
authPublicProcessRouter.get('/unlock-user', async (context, next) => {
|
|
92
82
|
const { token } = context.request.query
|
|
93
83
|
|
|
94
|
-
debug('get:/unlock-user', token)
|
|
95
|
-
|
|
96
84
|
await context.render('auth-page', {
|
|
97
85
|
pageElement: 'unlock-user',
|
|
98
86
|
elementScript: '/auth/unlock-user.js',
|
|
@@ -105,8 +93,6 @@ authPublicProcessRouter.get('/unlock-user', async (context, next) => {
|
|
|
105
93
|
authPublicProcessRouter.get('/activate/:email', async (context, next) => {
|
|
106
94
|
const { email } = context.params
|
|
107
95
|
|
|
108
|
-
debug('get:/activate/:email', email)
|
|
109
|
-
|
|
110
96
|
await context.render('auth-page', {
|
|
111
97
|
pageElement: 'auth-activate',
|
|
112
98
|
elementScript: '/auth/activate.js',
|
|
@@ -120,8 +106,6 @@ authPublicProcessRouter.get('/verify/:token', async (context, next) => {
|
|
|
120
106
|
const { header, t } = context
|
|
121
107
|
var token = context.params.token
|
|
122
108
|
|
|
123
|
-
debug('get:/verify/:token', token)
|
|
124
|
-
|
|
125
109
|
await verify(token)
|
|
126
110
|
|
|
127
111
|
var message = t('text.user activated successfully')
|
|
@@ -150,8 +134,6 @@ authPublicProcessRouter.post('/resend-verification-email', async (context, next)
|
|
|
150
134
|
context.status = 200
|
|
151
135
|
context.body = message
|
|
152
136
|
}
|
|
153
|
-
|
|
154
|
-
debug('get:/resend-verification-email', email)
|
|
155
137
|
})
|
|
156
138
|
|
|
157
139
|
authPublicProcessRouter.post('/resend-invitation-email', async (context, next) => {
|
|
@@ -173,8 +155,6 @@ authPublicProcessRouter.post('/resend-invitation-email', async (context, next) =
|
|
|
173
155
|
context.status = 200
|
|
174
156
|
context.body = message
|
|
175
157
|
}
|
|
176
|
-
|
|
177
|
-
debug('get:/resend-invitation-email', email)
|
|
178
158
|
})
|
|
179
159
|
|
|
180
160
|
authPublicProcessRouter.post('/forgot-password', async (context, next) => {
|
|
@@ -199,8 +179,6 @@ authPublicProcessRouter.post('/forgot-password', async (context, next) => {
|
|
|
199
179
|
context.status = 200
|
|
200
180
|
context.body = t('text.password reset email sent')
|
|
201
181
|
}
|
|
202
|
-
|
|
203
|
-
debug('post:/forgot-password', email)
|
|
204
182
|
})
|
|
205
183
|
|
|
206
184
|
authPublicProcessRouter.post('/reset-password', async (context, next) => {
|
|
@@ -234,8 +212,6 @@ authPublicProcessRouter.post('/reset-password', async (context, next) => {
|
|
|
234
212
|
|
|
235
213
|
await resetPassword(token, password, context)
|
|
236
214
|
|
|
237
|
-
debug('post:/reset-password', token)
|
|
238
|
-
|
|
239
215
|
var message = t('text.password reset succeed')
|
|
240
216
|
context.body = message
|
|
241
217
|
|
|
@@ -270,14 +246,10 @@ authPublicProcessRouter.post('/unlock-user', async (context, next) => {
|
|
|
270
246
|
const { header, t } = context
|
|
271
247
|
const { password, token } = context.request.body
|
|
272
248
|
|
|
273
|
-
debug('post:/unlock-user', token)
|
|
274
|
-
|
|
275
249
|
if (!(token || password)) {
|
|
276
250
|
context.status = 404
|
|
277
251
|
context.body = t('error.token or password is invalid')
|
|
278
252
|
|
|
279
|
-
debug('post:/unlock-user', 'token or password is invalid')
|
|
280
|
-
|
|
281
253
|
return
|
|
282
254
|
}
|
|
283
255
|
|
|
@@ -287,8 +259,6 @@ authPublicProcessRouter.post('/unlock-user', async (context, next) => {
|
|
|
287
259
|
context.body = t('text.password reset succeed')
|
|
288
260
|
|
|
289
261
|
clearAccessTokenCookie(context)
|
|
290
|
-
|
|
291
|
-
debug('post:/unlock-user', 'password reset succeed')
|
|
292
262
|
}
|
|
293
263
|
|
|
294
264
|
if (accepts(header.accept, ['text/html', '*/*'])) {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import Router from 'koa-router'
|
|
2
|
+
|
|
2
3
|
import { signinMiddleware } from '../middlewares'
|
|
3
4
|
import { accepts } from '../utils/accepts'
|
|
4
5
|
import { setAccessTokenCookie } from '../utils/access-token-cookie'
|
|
5
6
|
|
|
6
|
-
const debug = require('debug')('things-factory:auth-base:auth-signin-router')
|
|
7
|
-
|
|
8
7
|
export const authSigninRouter = new Router()
|
|
9
8
|
|
|
10
9
|
authSigninRouter.get('/auth/signin', async (context, next) => {
|
|
@@ -25,8 +24,6 @@ authSigninRouter.post('/auth/signin', signinMiddleware, async (context, next) =>
|
|
|
25
24
|
const { token, user, domain } = context.state
|
|
26
25
|
const { body: reqBody, header } = request
|
|
27
26
|
|
|
28
|
-
debug('post:/auth/signin', token?.substr(0, 20), user?.email, domain?.subdomain, redirectTo)
|
|
29
|
-
|
|
30
27
|
if (!accepts(header.accept, ['text/html', '*/*'])) {
|
|
31
28
|
context.body = token
|
|
32
29
|
return
|
|
@@ -38,6 +35,5 @@ authSigninRouter.post('/auth/signin', signinMiddleware, async (context, next) =>
|
|
|
38
35
|
|
|
39
36
|
setAccessTokenCookie(context, token)
|
|
40
37
|
|
|
41
|
-
debug('post:/auth/signin', redirectTo)
|
|
42
38
|
context.redirect(redirectTo)
|
|
43
39
|
})
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Router from 'koa-router'
|
|
2
|
+
|
|
2
3
|
import { config } from '@things-factory/env'
|
|
4
|
+
|
|
3
5
|
import { signup } from '../controllers/signup'
|
|
4
|
-
import { setAccessTokenCookie } from '../utils/access-token-cookie'
|
|
5
6
|
import { accepts } from '../utils/accepts'
|
|
6
|
-
|
|
7
|
-
const debug = require('debug')('things-factory:auth-base:auth-signup-router')
|
|
7
|
+
import { setAccessTokenCookie } from '../utils/access-token-cookie'
|
|
8
8
|
|
|
9
9
|
const passwordRule = config.get('password') || {
|
|
10
10
|
lowerCase: true,
|
|
@@ -23,8 +23,6 @@ export const authSignupRouter = new Router()
|
|
|
23
23
|
authSignupRouter.get('/auth/signup', async (context, next) => {
|
|
24
24
|
const { email } = context.query
|
|
25
25
|
|
|
26
|
-
debug('get:/auth/signup', email)
|
|
27
|
-
|
|
28
26
|
await context.render('auth-page', {
|
|
29
27
|
pageElement: 'auth-signup',
|
|
30
28
|
elementScript: '/auth/signup.js',
|
|
@@ -41,11 +39,6 @@ authSignupRouter.post('/auth/signup', async (context, next) => {
|
|
|
41
39
|
const user = context.request.body
|
|
42
40
|
|
|
43
41
|
try {
|
|
44
|
-
debug('post:/auth/signup', domain?.subdomain, {
|
|
45
|
-
...user,
|
|
46
|
-
password: 'N/A'
|
|
47
|
-
})
|
|
48
|
-
|
|
49
42
|
const { token } = await signup(
|
|
50
43
|
{
|
|
51
44
|
...user,
|