@vylth/nexus-react 1.0.2 → 1.0.3
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/index.js +16 -0
- package/dist/index.mjs +16 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -159,6 +159,9 @@ async function doRefresh(apiUrl) {
|
|
|
159
159
|
if (res.ok) {
|
|
160
160
|
const data = await res.json();
|
|
161
161
|
setTokens(data.access_token, data.refresh_token);
|
|
162
|
+
if (data.investor) {
|
|
163
|
+
saveUserProfile(data.investor.first_name, data.investor.last_name, data.investor.avatar_url || "");
|
|
164
|
+
}
|
|
162
165
|
return true;
|
|
163
166
|
}
|
|
164
167
|
} catch {
|
|
@@ -230,6 +233,19 @@ function NexusProvider({
|
|
|
230
233
|
if (isTokenValid()) {
|
|
231
234
|
const decoded = decodeUser(token);
|
|
232
235
|
if (decoded) {
|
|
236
|
+
if (!decoded.firstName) {
|
|
237
|
+
try {
|
|
238
|
+
const data = await nexusFetch(
|
|
239
|
+
resolvedApiUrl,
|
|
240
|
+
"/account/profile"
|
|
241
|
+
);
|
|
242
|
+
decoded.firstName = data.investor.first_name || "";
|
|
243
|
+
decoded.lastName = data.investor.last_name || "";
|
|
244
|
+
decoded.avatar = data.investor.avatar_url || decoded.avatar;
|
|
245
|
+
saveUserProfile(decoded.firstName, decoded.lastName, decoded.avatar);
|
|
246
|
+
} catch {
|
|
247
|
+
}
|
|
248
|
+
}
|
|
233
249
|
setUser(decoded);
|
|
234
250
|
setIsLoading(false);
|
|
235
251
|
return;
|
package/dist/index.mjs
CHANGED
|
@@ -122,6 +122,9 @@ async function doRefresh(apiUrl) {
|
|
|
122
122
|
if (res.ok) {
|
|
123
123
|
const data = await res.json();
|
|
124
124
|
setTokens(data.access_token, data.refresh_token);
|
|
125
|
+
if (data.investor) {
|
|
126
|
+
saveUserProfile(data.investor.first_name, data.investor.last_name, data.investor.avatar_url || "");
|
|
127
|
+
}
|
|
125
128
|
return true;
|
|
126
129
|
}
|
|
127
130
|
} catch {
|
|
@@ -193,6 +196,19 @@ function NexusProvider({
|
|
|
193
196
|
if (isTokenValid()) {
|
|
194
197
|
const decoded = decodeUser(token);
|
|
195
198
|
if (decoded) {
|
|
199
|
+
if (!decoded.firstName) {
|
|
200
|
+
try {
|
|
201
|
+
const data = await nexusFetch(
|
|
202
|
+
resolvedApiUrl,
|
|
203
|
+
"/account/profile"
|
|
204
|
+
);
|
|
205
|
+
decoded.firstName = data.investor.first_name || "";
|
|
206
|
+
decoded.lastName = data.investor.last_name || "";
|
|
207
|
+
decoded.avatar = data.investor.avatar_url || decoded.avatar;
|
|
208
|
+
saveUserProfile(decoded.firstName, decoded.lastName, decoded.avatar);
|
|
209
|
+
} catch {
|
|
210
|
+
}
|
|
211
|
+
}
|
|
196
212
|
setUser(decoded);
|
|
197
213
|
setIsLoading(false);
|
|
198
214
|
return;
|