@drax/identity-front 0.0.28 → 0.0.30
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 +5 -5
- package/src/i18n/identity-auth-i18n.ts +31 -0
- package/src/i18n/identity-validation-i18n.ts +2 -0
- package/src/i18n/index.ts +2 -1
- package/src/interfaces/IAuthProvider.ts +1 -1
- package/src/providers/gql/AuthGqlProvider.ts +13 -1
- package/src/providers/gql/RoleGqlProvider.ts +1 -1
- package/src/providers/gql/TenantGqlProvider.ts +1 -1
- package/src/providers/gql/UserGqlProvider.ts +1 -1
- package/src/providers/rest/AuthRestProvider.ts +8 -0
- package/src/providers/rest/UserRestProvider.ts +2 -0
- package/src/system/AuthSystem.ts +5 -0
- package/src/system/UserSystem.ts +2 -0
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.30",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./src/index.ts",
|
|
9
9
|
"module": "./src/index.ts",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"format": "prettier --write src/"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@drax/common-front": "^0.0.
|
|
28
|
-
"@drax/common-share": "^0.0.
|
|
29
|
-
"@drax/identity-share": "^0.0.
|
|
27
|
+
"@drax/common-front": "^0.0.30",
|
|
28
|
+
"@drax/common-share": "^0.0.30",
|
|
29
|
+
"@drax/identity-share": "^0.0.30"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@rushstack/eslint-patch": "^1.8.0",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"vite-plugin-dts": "^3.9.1",
|
|
49
49
|
"vitest": "^1.4.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "b0882d3ace0d0004cbc850e8d86381b9d6432535"
|
|
52
52
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const messages = {
|
|
2
|
+
en: {
|
|
3
|
+
auth: {
|
|
4
|
+
signIn: 'Sign In',
|
|
5
|
+
signUp: 'Sign Up',
|
|
6
|
+
login: 'Login',
|
|
7
|
+
logout: 'Logout',
|
|
8
|
+
username: 'Username',
|
|
9
|
+
password: 'Password',
|
|
10
|
+
rememberMe: 'Remember Me',
|
|
11
|
+
forgotPassword: 'Forgot Password?',
|
|
12
|
+
invalidCredentials: 'Invalid credentials',
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
es: {
|
|
16
|
+
auth: {
|
|
17
|
+
signIn: 'Iniciar Sesión',
|
|
18
|
+
signUp: 'Regístrate',
|
|
19
|
+
login: 'Iniciar Sesión',
|
|
20
|
+
logout: 'Cerrar Sesión',
|
|
21
|
+
username: 'Usuario',
|
|
22
|
+
password: 'Clave',
|
|
23
|
+
rememberMe: 'Recordarme',
|
|
24
|
+
forgotPassword: '¿Olvidaste tu clave?',
|
|
25
|
+
invalidCredentials: 'Credenciales Inválidas',
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export default messages
|
|
@@ -8,6 +8,7 @@ const messages = {
|
|
|
8
8
|
min8: 'Password must be at least 8 characters long',
|
|
9
9
|
max32: 'Password must be at most 32 characters long',
|
|
10
10
|
confirmed: 'Passwords do not match',
|
|
11
|
+
currentDifferent: 'New password must be different from current password'
|
|
11
12
|
},
|
|
12
13
|
}
|
|
13
14
|
},
|
|
@@ -20,6 +21,7 @@ const messages = {
|
|
|
20
21
|
min8: 'La contraseña debe tener al menos 8 caracteres',
|
|
21
22
|
max32: 'La contraseña debe tener como maximo 32 caracteres',
|
|
22
23
|
confirmed: 'Las contraseñas no coinciden',
|
|
24
|
+
currentDifferent: 'Nueva contraseña debe ser diferente de la actual'
|
|
23
25
|
},
|
|
24
26
|
}
|
|
25
27
|
}
|
package/src/i18n/index.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import merge from 'deepmerge'
|
|
2
|
+
import identityAuthI18n from "./identity-auth-i18n.js";
|
|
2
3
|
import identityValidationI18n from "./identity-validation-i18n.js";
|
|
3
4
|
import identityPermissionI18n from "./identity-permissions-i18n.js";
|
|
4
5
|
import identityUserI18n from "./identity-user-i18n.js";
|
|
5
6
|
import identityRoleI18n from "./identity-role-i18n.js";
|
|
6
7
|
import identityTenantI18n from "./identity-tenant-i18n.js";
|
|
7
8
|
|
|
8
|
-
const IdentityI18nMessages = merge.all([identityValidationI18n, identityUserI18n, identityRoleI18n, identityTenantI18n, identityPermissionI18n])
|
|
9
|
+
const IdentityI18nMessages = merge.all([identityAuthI18n, identityValidationI18n, identityUserI18n, identityRoleI18n, identityTenantI18n, identityPermissionI18n])
|
|
9
10
|
|
|
10
11
|
export default IdentityI18nMessages
|
|
11
12
|
export {IdentityI18nMessages}
|
|
@@ -34,7 +34,7 @@ class AuthGqlProvider implements IAuthProvider {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
async me(): Promise<IAuthUser> {
|
|
37
|
-
const query: string = `query me { me {id,username, email, role {id, name, permissions}} }`
|
|
37
|
+
const query: string = `query me { me {id, username, email, phone, role {id, name, permissions}, avatar} }`
|
|
38
38
|
let data = await this.gqlClient.query(query)
|
|
39
39
|
return data.me
|
|
40
40
|
}
|
|
@@ -54,6 +54,18 @@ class AuthGqlProvider implements IAuthProvider {
|
|
|
54
54
|
let r = await this.gqlClient.mutation(query, variables)
|
|
55
55
|
return /true/i.test(r as string)
|
|
56
56
|
}
|
|
57
|
+
|
|
58
|
+
async changeAvatar(file: File): Promise<boolean> {
|
|
59
|
+
//const query: string = `mutation changeAvatar( $file: File!) { changeAvatar }`
|
|
60
|
+
const operations = `{ "query": "mutation ($file: File!) { changeAvatar(file: $file) }", "variables": { "file": null } }`
|
|
61
|
+
const data = new FormData()
|
|
62
|
+
data.append("operations", operations)
|
|
63
|
+
const map = `{"0": ["variables.file"]}`
|
|
64
|
+
data.append("map", map)
|
|
65
|
+
data.append("0", file)
|
|
66
|
+
let r = await this.gqlClient.upload(data)
|
|
67
|
+
return /true/i.test(r as string)
|
|
68
|
+
}
|
|
57
69
|
}
|
|
58
70
|
|
|
59
71
|
export default AuthGqlProvider
|
|
@@ -60,7 +60,7 @@ class RoleGqlProvider implements IRoleProvider {
|
|
|
60
60
|
|
|
61
61
|
async paginate({page= 1, limit= 5, orderBy="", orderDesc=false, search = ""}): Promise<IDraxPaginateResult<IRole>> {
|
|
62
62
|
const query: string = `query paginateRole($options: PaginateOptions) {
|
|
63
|
-
paginateRole(
|
|
63
|
+
paginateRole(options: $options) {
|
|
64
64
|
total, page, limit, items{id name permissions childRoles{id name} readonly }
|
|
65
65
|
}
|
|
66
66
|
}`
|
|
@@ -54,7 +54,7 @@ class TenantGqlProvider implements ITenantProvider {
|
|
|
54
54
|
|
|
55
55
|
async paginate({page= 1, limit= 5, orderBy="", orderDesc=false, search = ""}): Promise<IDraxPaginateResult<ITenant>> {
|
|
56
56
|
const query: string = `query paginateTenant($options: PaginateOptions) {
|
|
57
|
-
paginateTenant(
|
|
57
|
+
paginateTenant(options: $options) {
|
|
58
58
|
total, page, limit, items{id, name }
|
|
59
59
|
}
|
|
60
60
|
}`
|
|
@@ -51,7 +51,7 @@ class UserGqlProvider implements IUserProvider {
|
|
|
51
51
|
|
|
52
52
|
async paginate({page= 1, limit= 5, orderBy="", orderDesc=false, search = ""}): Promise<IDraxPaginateResult<IUser>> {
|
|
53
53
|
const query: string = `query paginateUser($options: PaginateOptions) {
|
|
54
|
-
paginateUser(
|
|
54
|
+
paginateUser(options: $options) {
|
|
55
55
|
total, page, limit, items{ id, name username, email, phone, active, role{id, name} tenant{id name} }
|
|
56
56
|
}
|
|
57
57
|
}`
|
|
@@ -45,6 +45,14 @@ class AuthRestProvider implements IAuthProvider {
|
|
|
45
45
|
let r = await this.httpClient.post(url, data)
|
|
46
46
|
return /true/i.test(r as string)
|
|
47
47
|
}
|
|
48
|
+
|
|
49
|
+
async changeAvatar(file: File): Promise<boolean> {
|
|
50
|
+
const url = '/api/user/avatar'
|
|
51
|
+
const data = new FormData()
|
|
52
|
+
data.append('file', file)
|
|
53
|
+
let r = await this.httpClient.post(url, data, {removeHeaders: ['content-type']})
|
|
54
|
+
return /true/i.test(r as string)
|
|
55
|
+
}
|
|
48
56
|
}
|
|
49
57
|
|
|
50
58
|
export default AuthRestProvider
|
package/src/system/AuthSystem.ts
CHANGED
|
@@ -29,6 +29,11 @@ class AuthSystem {
|
|
|
29
29
|
const result: boolean = await this._provider.changeOwnPassword(currentPassword,newPassword)
|
|
30
30
|
return result
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
async changeAvatar(file: File):Promise<boolean> {
|
|
34
|
+
const result: boolean = await this._provider.changeAvatar(file)
|
|
35
|
+
return result
|
|
36
|
+
}
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
export default AuthSystem
|