@frontegg/rest-api 7.101.0-alpha.0 → 7.101.0-alpha.2
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/auth/index.js +4 -24
- package/index.js +1 -1
- package/node/auth/index.js +4 -24
- package/node/index.js +1 -1
- package/package.json +1 -1
package/auth/index.js
CHANGED
|
@@ -67,24 +67,14 @@ export class AuthenticationApi extends BaseApiClient {
|
|
|
67
67
|
const [me, currentUserTenants] = await Promise.all([this.getMeAndEntitlements(), getCurrentUserTenantsFunction(this.appName)()]);
|
|
68
68
|
const decodedContent = accessToken ? jwtDecode(accessToken) : {};
|
|
69
69
|
const user = _extends({}, loginResponse, decodedContent, me);
|
|
70
|
-
|
|
71
|
-
activeTenant
|
|
72
|
-
} = currentUserTenants;
|
|
73
|
-
if (contextHolder.isSessionPerTenantEnabled() && decodedContent.tenantId) {
|
|
74
|
-
user.tenantId = decodedContent.tenantId;
|
|
70
|
+
if (contextHolder.isSessionPerTenantEnabled()) {
|
|
75
71
|
setTabTenantInSessionStorage(user.tenantId);
|
|
76
|
-
// The server's activeTenant may reflect a different tab's tenant switch.
|
|
77
|
-
// Correct it to match the JWT's tenant for this tab.
|
|
78
|
-
const matchingTenant = currentUserTenants.tenants.find(t => t.tenantId === decodedContent.tenantId);
|
|
79
|
-
if (matchingTenant) {
|
|
80
|
-
activeTenant = matchingTenant;
|
|
81
|
-
}
|
|
82
72
|
}
|
|
83
73
|
contextHolder.setUser(user);
|
|
84
74
|
return {
|
|
85
75
|
user,
|
|
86
76
|
tenants: currentUserTenants.tenants,
|
|
87
|
-
activeTenant
|
|
77
|
+
activeTenant: currentUserTenants.activeTenant
|
|
88
78
|
};
|
|
89
79
|
};
|
|
90
80
|
this.generateLoginResponseFromOAuthResponse = async oauthResponse => {
|
|
@@ -114,24 +104,14 @@ export class AuthenticationApi extends BaseApiClient {
|
|
|
114
104
|
}, decodedContent, me, {
|
|
115
105
|
expiresIn: oauthResponse.expires_in || 300
|
|
116
106
|
});
|
|
117
|
-
|
|
118
|
-
activeTenant
|
|
119
|
-
} = currentUserTenants;
|
|
120
|
-
if (contextHolder.isSessionPerTenantEnabled() && decodedContent.tenantId) {
|
|
121
|
-
user.tenantId = decodedContent.tenantId;
|
|
107
|
+
if (contextHolder.isSessionPerTenantEnabled()) {
|
|
122
108
|
setTabTenantInSessionStorage(user.tenantId);
|
|
123
|
-
// The server's activeTenant may reflect a different tab's tenant switch.
|
|
124
|
-
// Correct it to match the JWT's tenant for this tab.
|
|
125
|
-
const matchingTenant = currentUserTenants.tenants.find(t => t.tenantId === decodedContent.tenantId);
|
|
126
|
-
if (matchingTenant) {
|
|
127
|
-
activeTenant = matchingTenant;
|
|
128
|
-
}
|
|
129
109
|
}
|
|
130
110
|
contextHolder.setUser(user);
|
|
131
111
|
return {
|
|
132
112
|
user,
|
|
133
113
|
tenants: currentUserTenants.tenants,
|
|
134
|
-
activeTenant
|
|
114
|
+
activeTenant: currentUserTenants.activeTenant
|
|
135
115
|
};
|
|
136
116
|
};
|
|
137
117
|
this.preLogin = async body => {
|
package/index.js
CHANGED
package/node/auth/index.js
CHANGED
|
@@ -132,24 +132,14 @@ class AuthenticationApi extends _BaseApiClient.BaseApiClient {
|
|
|
132
132
|
const [me, currentUserTenants] = await Promise.all([this.getMeAndEntitlements(), (0, _utils.getCurrentUserTenantsFunction)(this.appName)()]);
|
|
133
133
|
const decodedContent = accessToken ? (0, _jwt.jwtDecode)(accessToken) : {};
|
|
134
134
|
const user = (0, _extends2.default)({}, loginResponse, decodedContent, me);
|
|
135
|
-
|
|
136
|
-
activeTenant
|
|
137
|
-
} = currentUserTenants;
|
|
138
|
-
if (contextHolder.isSessionPerTenantEnabled() && decodedContent.tenantId) {
|
|
139
|
-
user.tenantId = decodedContent.tenantId;
|
|
135
|
+
if (contextHolder.isSessionPerTenantEnabled()) {
|
|
140
136
|
(0, _utils.setTabTenantInSessionStorage)(user.tenantId);
|
|
141
|
-
// The server's activeTenant may reflect a different tab's tenant switch.
|
|
142
|
-
// Correct it to match the JWT's tenant for this tab.
|
|
143
|
-
const matchingTenant = currentUserTenants.tenants.find(t => t.tenantId === decodedContent.tenantId);
|
|
144
|
-
if (matchingTenant) {
|
|
145
|
-
activeTenant = matchingTenant;
|
|
146
|
-
}
|
|
147
137
|
}
|
|
148
138
|
contextHolder.setUser(user);
|
|
149
139
|
return {
|
|
150
140
|
user,
|
|
151
141
|
tenants: currentUserTenants.tenants,
|
|
152
|
-
activeTenant
|
|
142
|
+
activeTenant: currentUserTenants.activeTenant
|
|
153
143
|
};
|
|
154
144
|
};
|
|
155
145
|
this.generateLoginResponseFromOAuthResponse = async oauthResponse => {
|
|
@@ -179,24 +169,14 @@ class AuthenticationApi extends _BaseApiClient.BaseApiClient {
|
|
|
179
169
|
}, decodedContent, me, {
|
|
180
170
|
expiresIn: oauthResponse.expires_in || 300
|
|
181
171
|
});
|
|
182
|
-
|
|
183
|
-
activeTenant
|
|
184
|
-
} = currentUserTenants;
|
|
185
|
-
if (contextHolder.isSessionPerTenantEnabled() && decodedContent.tenantId) {
|
|
186
|
-
user.tenantId = decodedContent.tenantId;
|
|
172
|
+
if (contextHolder.isSessionPerTenantEnabled()) {
|
|
187
173
|
(0, _utils.setTabTenantInSessionStorage)(user.tenantId);
|
|
188
|
-
// The server's activeTenant may reflect a different tab's tenant switch.
|
|
189
|
-
// Correct it to match the JWT's tenant for this tab.
|
|
190
|
-
const matchingTenant = currentUserTenants.tenants.find(t => t.tenantId === decodedContent.tenantId);
|
|
191
|
-
if (matchingTenant) {
|
|
192
|
-
activeTenant = matchingTenant;
|
|
193
|
-
}
|
|
194
174
|
}
|
|
195
175
|
contextHolder.setUser(user);
|
|
196
176
|
return {
|
|
197
177
|
user,
|
|
198
178
|
tenants: currentUserTenants.tenants,
|
|
199
|
-
activeTenant
|
|
179
|
+
activeTenant: currentUserTenants.activeTenant
|
|
200
180
|
};
|
|
201
181
|
};
|
|
202
182
|
this.preLogin = async body => {
|
package/node/index.js
CHANGED