shared-ritm 1.3.45 → 1.3.48
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/shared-ritm.es.js +1269 -1261
- package/dist/shared-ritm.umd.js +149 -149
- package/dist/types/api/services/AuthService.d.ts +1 -0
- package/dist/types/api/settings/ApiService.d.ts +2 -2
- package/dist/types/api/types/Api_Auth.d.ts +6 -0
- package/package.json +1 -1
- package/src/api/services/AuthService.ts +14 -0
- package/src/api/settings/ApiService.ts +18 -10
- package/src/api/types/Api_Auth.ts +7 -0
|
@@ -8,6 +8,7 @@ declare class AuthService extends ApiService {
|
|
|
8
8
|
userInfo(): Promise<any>;
|
|
9
9
|
configs(): Promise<ConfigResponse>;
|
|
10
10
|
changePassword(id: string, password: string, password_confirmation: string): Promise<ChangePasswordResponse>;
|
|
11
|
+
changePasswordAndActivate(email: string, currentPassword: string, password: string, passwordConfirmation: string): Promise<any>;
|
|
11
12
|
}
|
|
12
13
|
export default function useAuthService(): AuthService;
|
|
13
14
|
export {};
|
|
@@ -73,5 +73,11 @@ export type ChangePasswordPayload = {
|
|
|
73
73
|
password: string;
|
|
74
74
|
password_confirmation: string;
|
|
75
75
|
};
|
|
76
|
+
export type ChangePasswordAndActivatePayload = {
|
|
77
|
+
email: string;
|
|
78
|
+
currentPassword: string;
|
|
79
|
+
password: string;
|
|
80
|
+
passwordConfirmation: string;
|
|
81
|
+
};
|
|
76
82
|
export type ChangePasswordResponse = Pick<Api_User, 'id' | 'archiveHistory' | 'assigned_tasks' | 'divisions' | 'email' | 'full_name' | 'passes' | 'personnel_number' | 'phone' | 'photos' | 'positions' | 'responsible_tasks' | 'teams' | 'warehouses'>;
|
|
77
83
|
export type ConfigResponse = any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import ApiService from '../settings/ApiService'
|
|
2
2
|
import {
|
|
3
3
|
Api_Auth_Login,
|
|
4
|
+
ChangePasswordAndActivatePayload,
|
|
4
5
|
ChangePasswordPayload,
|
|
5
6
|
ChangePasswordResponse,
|
|
6
7
|
ConfigResponse,
|
|
@@ -43,6 +44,19 @@ class AuthService extends ApiService {
|
|
|
43
44
|
password_confirmation,
|
|
44
45
|
})
|
|
45
46
|
}
|
|
47
|
+
public changePasswordAndActivate(
|
|
48
|
+
email: string,
|
|
49
|
+
currentPassword: string,
|
|
50
|
+
password: string,
|
|
51
|
+
passwordConfirmation: string,
|
|
52
|
+
) {
|
|
53
|
+
return this.post<ChangePasswordAndActivatePayload, ChangePasswordResponse>(`/v2/auth/users/activate`, {
|
|
54
|
+
email,
|
|
55
|
+
currentPassword,
|
|
56
|
+
password,
|
|
57
|
+
passwordConfirmation,
|
|
58
|
+
})
|
|
59
|
+
}
|
|
46
60
|
}
|
|
47
61
|
|
|
48
62
|
let api: AuthService
|
|
@@ -26,9 +26,9 @@ export default class ApiService {
|
|
|
26
26
|
|
|
27
27
|
this.axiosInstance.interceptors.request.use(
|
|
28
28
|
(config: InternalAxiosRequestConfig) => {
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
config.headers.Authorization = `Bearer ${
|
|
29
|
+
const access_token = this.getAccessToken()
|
|
30
|
+
if (access_token && config.headers) {
|
|
31
|
+
config.headers.Authorization = `Bearer ${access_token}`
|
|
32
32
|
}
|
|
33
33
|
return config
|
|
34
34
|
},
|
|
@@ -41,16 +41,25 @@ export default class ApiService {
|
|
|
41
41
|
(response: AxiosResponse) => {
|
|
42
42
|
return response.data
|
|
43
43
|
},
|
|
44
|
-
async
|
|
44
|
+
async error => {
|
|
45
|
+
const originalRequest = error.config
|
|
46
|
+
|
|
47
|
+
if (originalRequest?._retry) {
|
|
48
|
+
throw error
|
|
49
|
+
}
|
|
50
|
+
|
|
45
51
|
if (error.response?.status === 401 || error.response?.status === 403) {
|
|
46
|
-
if (
|
|
52
|
+
if (!this.getAccessToken()) return Promise.reject(error)
|
|
53
|
+
if (!this.isRefresh) {
|
|
54
|
+
originalRequest._retry = true
|
|
47
55
|
this.isRefresh = true
|
|
48
56
|
return this.refresh().then(response => {
|
|
49
57
|
if (!response?.accessToken) {
|
|
50
|
-
|
|
58
|
+
this.logoutUser()
|
|
51
59
|
}
|
|
52
60
|
if (response?.accessToken) {
|
|
53
|
-
|
|
61
|
+
this.setAccessToken(response.accessToken)
|
|
62
|
+
this.axiosInstance(originalRequest)
|
|
54
63
|
}
|
|
55
64
|
})
|
|
56
65
|
}
|
|
@@ -61,11 +70,10 @@ export default class ApiService {
|
|
|
61
70
|
)
|
|
62
71
|
}
|
|
63
72
|
|
|
64
|
-
private
|
|
73
|
+
private setAccessToken(token: string) {
|
|
65
74
|
localStorage.setItem('token', token)
|
|
66
75
|
}
|
|
67
|
-
|
|
68
|
-
private getToken() {
|
|
76
|
+
private getAccessToken() {
|
|
69
77
|
return localStorage.getItem('token')
|
|
70
78
|
}
|
|
71
79
|
|
|
@@ -84,6 +84,13 @@ export type ChangePasswordPayload = {
|
|
|
84
84
|
password_confirmation: string
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
export type ChangePasswordAndActivatePayload = {
|
|
88
|
+
email: string
|
|
89
|
+
currentPassword: string
|
|
90
|
+
password: string
|
|
91
|
+
passwordConfirmation: string
|
|
92
|
+
}
|
|
93
|
+
|
|
87
94
|
export type ChangePasswordResponse = Pick<
|
|
88
95
|
Api_User,
|
|
89
96
|
| 'id'
|