@things-factory/auth-base 6.2.49 → 6.2.50

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/auth-base",
3
- "version": "6.2.49",
3
+ "version": "6.2.50",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -30,10 +30,10 @@
30
30
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
31
31
  },
32
32
  "dependencies": {
33
- "@things-factory/email-base": "^6.2.48",
33
+ "@things-factory/email-base": "^6.2.50",
34
34
  "@things-factory/env": "^6.2.33",
35
- "@things-factory/i18n-base": "^6.2.48",
36
- "@things-factory/shell": "^6.2.48",
35
+ "@things-factory/i18n-base": "^6.2.50",
36
+ "@things-factory/shell": "^6.2.50",
37
37
  "@things-factory/utils": "^6.2.48",
38
38
  "jsonwebtoken": "^9.0.0",
39
39
  "koa-passport": "^6.0.0",
@@ -43,5 +43,5 @@
43
43
  "passport-local": "^1.0.0",
44
44
  "popsicle-cookie-jar": "^1.0.0"
45
45
  },
46
- "gitHead": "57266c96220301729f9c5cd633af1a4e2a651096"
46
+ "gitHead": "4dc51db04b745ac434d2bb874038ac4c3b47989b"
47
47
  }
@@ -14,4 +14,4 @@ export const CONFIRM_PASSWORD_NOT_MATCHED = 'confirm password not matched'
14
14
  export const PASSWORD_PATTERN_NOT_MATCHED = 'password should match the rule'
15
15
  export const USER_DUPLICATED = 'user duplicated'
16
16
  export const PASSWORD_USED_PAST = 'password used in the past'
17
- export const VERIFICATION_ERROR = 'user or verification token not found'
17
+ export const VERIFICATION_ERROR = 'user or verification token not found'
@@ -67,11 +67,19 @@ authPrivateProcessRouter
67
67
  clearAccessTokenCookie(context)
68
68
  })
69
69
  .get('/profile', async (context, next) => {
70
- const { domain, user, protected: protectedIP } = context.state
70
+ const { domain, user, unsafeIP, prohibitedPrivileges } = context.state
71
71
 
72
72
  let domains: Partial<Domain>[] = await getUserDomains(user)
73
73
  domains = domains.filter((d: Domain) => d.extType == domainType)
74
74
 
75
+ var privileges = await User.getPrivilegesByDomain(user, domain)
76
+
77
+ if (prohibitedPrivileges) {
78
+ prohibitedPrivileges.forEach(({ category, name }) => {
79
+ privileges = privileges.filter(p => p.category != category || p.name != name)
80
+ })
81
+ }
82
+
75
83
  context.body = {
76
84
  user: {
77
85
  email: user.email,
@@ -79,8 +87,8 @@ authPrivateProcessRouter
79
87
  userType: user.userType,
80
88
  owner: await process.domainOwnerGranted(domain, user),
81
89
  super: await process.superUserGranted(domain, user),
82
- protected: protectedIP,
83
- privileges: await User.getPrivilegesByDomain(user, domain)
90
+ unsafeIP,
91
+ privileges
84
92
  },
85
93
  domains,
86
94
  domain: domain && {
@@ -11,7 +11,7 @@ import { DomainGeneratorInput, DomainUserRoleInput } from './domain-generator-ty
11
11
 
12
12
  @Resolver()
13
13
  export class DomainGeneratorMutation {
14
- @Directive('@privilege(category: "system", privilege: "mutation", superUserGranted: true)')
14
+ @Directive('@privilege(category: "domain", privilege: "mutation", superUserGranted: true)')
15
15
  @Directive('@transaction')
16
16
  @Mutation(returns => Domain)
17
17
  async domainRegister(
@@ -46,7 +46,7 @@ export class PartnerMutation {
46
46
 
47
47
  // Find partner
48
48
  const partner: Partner = await tx.getRepository(Partner).findOne({
49
- where: { domain: { id: domain.id }, partnerDomain }
49
+ where: { domain: { id: domain.id }, partnerDomain: { id: partnerDomain.id } }
50
50
  })
51
51
  if (!partner) throw new Error(context.t('error.failed to find x', { x: context.t('label.partner') }))
52
52
 
@@ -43,7 +43,7 @@ export const privilegeDirectiveResolver = (schema: GraphQLSchema) =>
43
43
  return await resolve.call(this, source, args, context, info)
44
44
  }
45
45
 
46
- if (!category || !privilege) throw new Error(`Unauthorized! ${category}-${privilege} privilege required`)
46
+ if (!category || !privilege) throw new Error(`Unauthorized! Access restricted to authorized personnel only`)
47
47
 
48
48
  if (await User.hasPrivilege(privilege, category, domain, user)) {
49
49
  return await resolve.call(this, source, args, context, info)
@@ -1,55 +1,55 @@
1
1
  {
2
- "field.email": "e-mel",
3
- "field.password": "kata-laluan",
4
- "field.token": "token",
5
- "field.appliance_id": "perkakas",
6
- "field.brand": "jenama",
7
- "field.model": "model",
8
- "field.active": "aktif",
9
- "field.category": "kategori",
10
- "field.roles": "peranan",
11
- "field.privileges": "keistimewaan",
12
- "field.user": "pengguna",
13
- "field.user_type": "[ms] user type",
14
- "field.user_account": "akaun pengguna",
15
- "label.partner": "[ms] partner",
16
- "text.account is reactivated": "[ms] account is reactivated",
17
- "text.delete account succeed": "[ms] delete account succeed",
18
- "text.inactive user": "[ms] inactive user",
19
- "text.invalid verification token": "[ms] invalid verification token",
20
- "text.invitation email sent": "[ms] invitation email sent",
21
- "text.pattern_minimum_charaters": "[ms] minimum {length} charaters",
22
- "text.pattern_atleast_1_lowercase": "[ms] at least 1 lowercase character",
23
- "text.pattern_atleast_1_uppercase": "[ms] at least 1 uppercase character",
24
- "text.pattern_atleast_1_digit": "[ms] at least 1 digit character",
25
- "text.pattern_atleast_1_special": "[ms] at least 1 special character(!@#$%^&*())",
26
- "text.pattern_not_allowed": "[ms] not allowed repeated charater",
27
- "text.password reset succeed": "[ms] password reset succeed",
28
- "text.password changed successfully": "[ms] password changed successfully",
29
- "text.profile changed successfully": "[ms] profile changed successfully",
30
- "text.result": "[ms] result",
31
- "text.signout successfully": "[ms] signout successfully",
32
- "text.user registered successfully": "[ms] user registered successfully. find your email to activate account",
33
- "text.user activated successfully": "[ms] user activated successfully",
34
- "text.password reset email sent": "[ms] password reset email sent",
35
- "text.verification email sent": "[ms] verification email sent",
36
- "error.confirm password not matched": "[ms] new password and confirm password is not matched",
37
- "error.domain not allowed": "[ms] user not allowed domain `{subdomain}`",
38
- "error.domain mismatch": "[ms] certificate is not for this domain",
39
- "error.failed to find x": "[ms] failed to find {x}",
40
- "error.password should match the rule": "[ms] password should match following rule. ${rule}",
41
- "error.password used in the past": "[ms] password used in the past",
42
- "error.subdomain not found": "[ms] domain not found",
43
- "error.token or password is invalid": "[ms] token or password is invalid",
44
- "error.unavailable-domain": "[ms] unavailable domain",
45
- "error.user not found": "pengguna tidak wujud",
46
- "error.user duplicated": "emel telah diguna oleh akaun lain",
47
- "error.user or verification token not found": "[ms] user or verification token not found",
48
- "error.user validation failed": "[ms] user validation failed",
49
- "error.user not activated": "[ms] user is not activated",
50
- "error.x is not a member of y": "[ms] {x} is not a member of {y}",
51
- "privilege.category.system": "[ms] system setting",
52
- "privilege.description": "[ms] to {name} {category} data",
53
- "privilege.name.mutation": "[ms] edit",
54
- "privilege.name.query": "[ms] read"
2
+ "error.confirm password not matched": "Kata laluan baru dan pengesahan kata laluan tidak sepadan",
3
+ "error.domain mismatch": "Sijil tidak sesuai untuk domain ini",
4
+ "error.domain not allowed": "Pengguna tidak dibenarkan domain `{subdomain}`",
5
+ "error.failed to find x": "Gagal mencari {x}",
6
+ "error.password should match the rule": "Kata laluan harus mematuhi peraturan berikut. ${rule}",
7
+ "error.password used in the past": "Kata laluan telah digunakan dalam masa lampau",
8
+ "error.subdomain not found": "Domain tidak ditemui",
9
+ "error.token or password is invalid": "Token atau kata laluan tidak sah",
10
+ "error.unavailable-domain": "Domain tidak tersedia",
11
+ "error.user duplicated": "Emel telah digunakan oleh akaun lain",
12
+ "error.user not activated": "Pengguna tidak diaktifkan",
13
+ "error.user not found": "Pengguna tidak ditemui",
14
+ "error.user or verification token not found": "Pengguna atau token pengesahan tidak ditemui",
15
+ "error.user validation failed": "Validasi pengguna gagal",
16
+ "error.x is not a member of y": "{x} bukan ahli {y}",
17
+ "field.active": "Aktif",
18
+ "field.appliance_id": "Perkakas",
19
+ "field.brand": "Jenama",
20
+ "field.category": "Kategori",
21
+ "field.email": "E-mel",
22
+ "field.model": "Model",
23
+ "field.password": "Kata laluan",
24
+ "field.privileges": "Keistimewaan",
25
+ "field.roles": "Peranan",
26
+ "field.token": "Token",
27
+ "field.user": "Pengguna",
28
+ "field.user_account": "Akaun pengguna",
29
+ "field.user_type": "Jenis pengguna",
30
+ "label.partner": "Rakan kongsi",
31
+ "privilege.category.system": "Tetapan sistem",
32
+ "privilege.description": "Untuk {name} data {category}",
33
+ "privilege.name.mutation": "Sunting",
34
+ "privilege.name.query": "Baca",
35
+ "text.account is reactivated": "Akaun telah diaktifkan semula",
36
+ "text.delete account succeed": "Berjaya memadam akaun",
37
+ "text.inactive user": "Pengguna tidak aktif",
38
+ "text.invalid verification token": "Token pengesahan tidak sah",
39
+ "text.invitation email sent": "E-mel jemputan telah dihantar",
40
+ "text.password changed successfully": "Kata laluan berjaya diubah",
41
+ "text.password reset email sent": "E-mel reset kata laluan telah dihantar",
42
+ "text.password reset succeed": "Reset kata laluan berjaya",
43
+ "text.pattern_atleast_1_digit": "Sekurang-kurangnya 1 aksara digit",
44
+ "text.pattern_atleast_1_lowercase": "Sekurang-kurangnya 1 aksara kecil",
45
+ "text.pattern_atleast_1_special": "Sekurang-kurangnya 1 aksara istimewa (!@#$%^&*())",
46
+ "text.pattern_atleast_1_uppercase": "Sekurang-kurangnya 1 aksara besar",
47
+ "text.pattern_minimum_charaters": "Minimum {length} aksara",
48
+ "text.pattern_not_allowed": "Tidak dibenarkan aksara berulang",
49
+ "text.profile changed successfully": "Profil berjaya diubah",
50
+ "text.result": "Hasil",
51
+ "text.signout successfully": "Berjaya keluar",
52
+ "text.user activated successfully": "Pengguna diaktifkan dengan berjaya",
53
+ "text.user registered successfully": "Pengguna berjaya didaftarkan. Cari e-mel anda untuk mengaktifkan akaun",
54
+ "text.verification email sent": "E-mel pengesahan telah dihantar"
55
55
  }
@@ -1,55 +1,55 @@
1
1
  {
2
- "field.email": "电子邮件地址",
3
- "field.password": "密码",
4
- "field.token": "符记",
2
+ "error.confirm password not matched": "新密码与确认密码不匹配!",
3
+ "error.domain mismatch": "证书不适用于该域!",
4
+ "error.domain not allowed": "用户无权限使用`{subdomain}`域!",
5
+ "error.failed to find x": "查询{x}失败!",
6
+ "error.password should match the rule": "密码应符合以下规则。${rule}",
7
+ "error.password used in the past": "使用过的密码!",
8
+ "error.subdomain not found": "用户域查询失败!",
9
+ "error.token or password is invalid": "令牌或密码无效!",
10
+ "error.unavailable-domain": "不可用的域名",
11
+ "error.user duplicated": "有一个用户帐户使用相同的电子邮件",
12
+ "error.user not activated": "用户未激活!",
13
+ "error.user not found": "找不到用户",
14
+ "error.user or verification token not found": "找不到用户或验证令牌。",
15
+ "error.user validation failed": "用户验证失败!",
16
+ "error.x is not a member of y": "{x}不是{y}的成员",
17
+ "field.active": "激活",
5
18
  "field.appliance_id": "终端机ID",
6
19
  "field.brand": "品牌",
7
- "field.model": "模型",
8
- "field.active": "激活",
9
20
  "field.category": "分类",
10
- "field.roles": "角色",
21
+ "field.email": "电子邮件地址",
22
+ "field.model": "模型",
23
+ "field.password": "密码",
11
24
  "field.privileges": "权限",
25
+ "field.roles": "角色",
26
+ "field.token": "符记",
12
27
  "field.user": "用户",
13
- "field.user_type": "用户类型",
14
28
  "field.user_account": "用户账号",
29
+ "field.user_type": "用户类型",
15
30
  "label.partner": "合作伙伴",
31
+ "privilege.category.system": "系统配置",
32
+ "privilege.description": "{name} {category}数据",
33
+ "privilege.name.mutation": "编辑",
34
+ "privilege.name.query": "查询",
16
35
  "text.account is reactivated": "账户已经重新激活。",
17
36
  "text.delete account succeed": "已成功删除账号。",
18
37
  "text.inactive user": "未激活用账号。",
19
38
  "text.invalid verification token": "令牌无效。",
20
39
  "text.invitation email sent": "成功发送邀请电子邮件。",
21
- "text.pattern_minimum_charaters": "最少未字符长度为{length}",
22
- "text.pattern_atleast_1_lowercase": "至少1个小写字母",
23
- "text.pattern_atleast_1_uppercase": "至少1个大写字母",
40
+ "text.password changed successfully": "密码更改成功。",
41
+ "text.password reset email sent": "已发送密码重置邮件。",
42
+ "text.password reset succeed": "密码重置成功。",
24
43
  "text.pattern_atleast_1_digit": "至少1位数字字符",
44
+ "text.pattern_atleast_1_lowercase": "至少1个小写字母",
25
45
  "text.pattern_atleast_1_special": "至少1个特殊字符(!@#$%^&*())",
46
+ "text.pattern_atleast_1_uppercase": "至少1个大写字母",
47
+ "text.pattern_minimum_charaters": "最少未字符长度为{length}",
26
48
  "text.pattern_not_allowed": "不允许重复字符",
27
- "text.password reset succeed": "密码重置成功。",
28
- "text.password changed successfully": "密码更改成功。",
29
49
  "text.profile changed successfully": "个人资料更改成功。",
30
50
  "text.result": "结果",
31
51
  "text.signout successfully": "登出成功。",
32
- "text.user registered successfully": "用户注册成功。 请查看电子邮件以激活帐户。",
33
52
  "text.user activated successfully": "用户激活成功",
34
- "text.password reset email sent": "已发送密码重置邮件。",
35
- "text.verification email sent": "验证邮件已发送",
36
- "error.confirm password not matched": "新密码与确认密码不匹配!",
37
- "error.domain not allowed": "用户无权限使用`{subdomain}`域!",
38
- "error.domain mismatch": "证书不适用于该域!",
39
- "error.failed to find x": "查询{x}失败!",
40
- "error.password should match the rule": "密码应符合以下规则。${rule}",
41
- "error.password used in the past": "使用过的密码!",
42
- "error.subdomain not found": "用户域查询失败!",
43
- "error.token or password is invalid": "令牌或密码无效!",
44
- "error.unavailable-domain": "[zh] unavailable domain",
45
- "error.user not found": "找不到用户",
46
- "error.user duplicated": "有一个用户帐户使用相同的电子邮件",
47
- "error.user or verification token not found": "找不到用户或验证令牌。",
48
- "error.user validation failed": "用户验证失败!",
49
- "error.user not activated": "用户未激活!",
50
- "error.x is not a member of y": "{x}不是{y}的成员",
51
- "privilege.category.system": "系统配置",
52
- "privilege.description": "{name} {category}数据",
53
- "privilege.name.mutation": "编辑",
54
- "privilege.name.query": "查询"
55
- }
53
+ "text.user registered successfully": "用户注册成功。 请查看电子邮件以激活帐户。",
54
+ "text.verification email sent": "验证邮件已发送"
55
+ }