shared-ritm 1.3.46 → 1.3.49

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.
@@ -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,6 @@
1
1
  {
2
2
  "name": "shared-ritm",
3
- "version": "1.3.46",
3
+ "version": "1.3.49",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist",
@@ -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
@@ -49,24 +49,22 @@ export default class ApiService {
49
49
  }
50
50
 
51
51
  if (error.response?.status === 401 || error.response?.status === 403) {
52
- if (!!this.getAccessToken() && !this.isRefresh) {
52
+ if (!this.getAccessToken()) return Promise.reject(error)
53
+ if (!this.isRefresh) {
53
54
  originalRequest._retry = true
54
55
  this.isRefresh = true
55
56
  return this.refresh().then(response => {
56
57
  if (!response?.accessToken) {
57
58
  this.logoutUser()
58
- return
59
59
  }
60
60
  if (response?.accessToken) {
61
61
  this.setAccessToken(response.accessToken)
62
62
  this.axiosInstance(originalRequest)
63
- return
64
63
  }
65
64
  })
66
65
  }
67
66
  return this.logoutUser()
68
67
  }
69
- return Promise.reject(error)
70
68
  },
71
69
  )
72
70
  }
@@ -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'