@things-factory/auth-base 7.0.70 → 7.0.71

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": "7.0.70",
3
+ "version": "7.0.71",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -46,5 +46,5 @@
46
46
  "passport-jwt": "^4.0.0",
47
47
  "passport-local": "^1.0.0"
48
48
  },
49
- "gitHead": "f046cfbb15447499fc5be9a9d82e2deb296b5f36"
49
+ "gitHead": "d242e4a4415764d0d389e9dff09d2ce3a8fc317f"
50
50
  }
@@ -42,6 +42,7 @@ export async function changePwd(attrs, currentPass, newPass, confirmPass, contex
42
42
  }
43
43
  })
44
44
  }
45
+
45
46
  /* check if password is following the rule */
46
47
  User.validatePasswordByRule(newPass, context?.lng)
47
48
 
@@ -3,17 +3,31 @@ import { GraphQLEmailAddress } from 'graphql-scalars'
3
3
  import { ILike, SelectQueryBuilder } from 'typeorm'
4
4
 
5
5
  import { config } from '@things-factory/env'
6
- import { Domain, getRepository, ListParam, getQueryBuilderFromListParams } from '@things-factory/shell'
6
+ import { getRepository, ListParam, getQueryBuilderFromListParams } from '@things-factory/shell'
7
7
 
8
8
  import { checkUserBelongsDomain } from '../../utils/check-user-belongs-domain'
9
9
  import { buildDomainUsersQueryBuilder } from '../../utils/get-domain-users'
10
- import { Appliance } from '../appliance/appliance'
11
- import { Application } from '../application/application'
12
10
  import { User } from './user'
13
- import { UserList } from './user-types'
11
+ import { PasswordRule, UserList } from './user-types'
12
+
13
+ const passwordRule = config.get('password') || {
14
+ lowerCase: true,
15
+ upperCase: true,
16
+ digit: true,
17
+ specialCharacter: true,
18
+ allowRepeat: false,
19
+ useTightPattern: true,
20
+ useLoosePattern: false,
21
+ tightCharacterLength: 8,
22
+ looseCharacterLength: 15
23
+ }
14
24
 
15
25
  @Resolver(User)
16
26
  export class UserQuery {
27
+ @Query(returns => PasswordRule, { description: 'To get password rule' })
28
+ passwordRule(@Ctx() context: ResolverContext): PasswordRule {
29
+ return passwordRule
30
+ }
17
31
  @Directive('@privilege(category: "user", privilege: "query", domainOwnerGranted: true, superUserGranted: true)')
18
32
  @Query(returns => User, { description: 'To fetch user' })
19
33
  async user(@Arg('email', type => GraphQLEmailAddress) email: string, @Ctx() context: ResolverContext): Promise<User> {
@@ -3,6 +3,36 @@ import { GraphQLEmailAddress } from 'graphql-scalars'
3
3
  import { ObjectRef } from '@things-factory/shell'
4
4
  import { User } from './user'
5
5
 
6
+ @ObjectType()
7
+ export class PasswordRule {
8
+ @Field({ nullable: true })
9
+ lowerCase?: boolean
10
+
11
+ @Field({ nullable: true })
12
+ upperCase?: boolean
13
+
14
+ @Field({ nullable: true })
15
+ digit?: boolean
16
+
17
+ @Field({ nullable: true })
18
+ specialCharacter?: boolean
19
+
20
+ @Field({ nullable: true })
21
+ allowRepeat?: boolean
22
+
23
+ @Field({ nullable: true })
24
+ useTightPattern?: boolean
25
+
26
+ @Field({ nullable: true })
27
+ useLoosePattern?: boolean
28
+
29
+ @Field({ nullable: true })
30
+ tightCharacterLength?: number
31
+
32
+ @Field({ nullable: true })
33
+ looseCharacterLength?: number
34
+ }
35
+
6
36
  @InputType()
7
37
  export class NewUser {
8
38
  @Field()