@riligar/auth-react 1.23.0 → 1.24.0

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 CHANGED
@@ -8,7 +8,6 @@ var reactRouterDom = require('react-router-dom');
8
8
  var core = require('@mantine/core');
9
9
  var form = require('@mantine/form');
10
10
  var iconsReact = require('@tabler/icons-react');
11
- var notifications = require('@mantine/notifications');
12
11
 
13
12
  // Config - API Base URL fixa para o serviço de autenticação
14
13
  let API_BASE = 'https://manager.myauth.click';
@@ -2075,6 +2074,8 @@ function UserProfile({
2075
2074
  onProfileUpdate,
2076
2075
  onPasswordChange,
2077
2076
  onEmailChange,
2077
+ onSessionRevoked,
2078
+ onOtherSessionsRevoked,
2078
2079
  onError,
2079
2080
  // Features toggle
2080
2081
  showAvatar = true,
@@ -2161,7 +2162,9 @@ function UserProfile({
2161
2162
  if (isCurrentSession) {
2162
2163
  try {
2163
2164
  await revokeSession(sessionId);
2165
+ onSessionRevoked?.(sessionId);
2164
2166
  } catch (error) {
2167
+ onError?.(error);
2165
2168
  // Even if it fails, we're revoking our own session, so just logout
2166
2169
  // The server already revoked our session
2167
2170
  }
@@ -2175,11 +2178,7 @@ function UserProfile({
2175
2178
  // Revoking another session
2176
2179
  try {
2177
2180
  await revokeSession(sessionId);
2178
- notifications.notifications.show({
2179
- title: labels.successTitle || 'Sucesso',
2180
- message: labels.sessionRevoked || 'Sessão encerrada com sucesso',
2181
- color: 'green'
2182
- });
2181
+ onSessionRevoked?.(sessionId);
2183
2182
  } catch (error) {
2184
2183
  // Check for 401 error (our SDK uses error.res, axios uses error.response)
2185
2184
  const status = error.res?.status || error.response?.status;
@@ -2190,28 +2189,14 @@ function UserProfile({
2190
2189
  if (variant === 'modal') onClose?.();
2191
2190
  return;
2192
2191
  }
2193
- notifications.notifications.show({
2194
- title: labels.errorTitle || 'Erro',
2195
- message: error.message || labels.sessionRevokeFailed || 'Falha ao encerrar sessão',
2196
- color: 'red'
2197
- });
2198
2192
  onError?.(error);
2199
2193
  }
2200
2194
  };
2201
2195
  const handleRevokeOtherSessions = async () => {
2202
2196
  try {
2203
2197
  await revokeOtherSessions();
2204
- notifications.notifications.show({
2205
- title: labels.successTitle || 'Sucesso',
2206
- message: labels.otherSessionsRevoked || 'Todas as outras sessões foram encerradas',
2207
- color: 'green'
2208
- });
2198
+ onOtherSessionsRevoked?.();
2209
2199
  } catch (error) {
2210
- notifications.notifications.show({
2211
- title: labels.errorTitle || 'Erro',
2212
- message: error.message || labels.otherSessionsRevokeFailed || 'Falha ao encerrar sessões',
2213
- color: 'red'
2214
- });
2215
2200
  onError?.(error);
2216
2201
  }
2217
2202
  };
@@ -2272,21 +2257,13 @@ function UserProfile({
2272
2257
 
2273
2258
  // Validate file type
2274
2259
  if (!file.type.startsWith('image/')) {
2275
- notifications.notifications.show({
2276
- title: labels.errorTitle || 'Erro',
2277
- message: labels.avatarInvalidType || 'Por favor, selecione uma imagem válida',
2278
- color: 'red'
2279
- });
2260
+ onError?.(new Error(labels.avatarInvalidType || 'Por favor, selecione uma imagem válida'));
2280
2261
  return;
2281
2262
  }
2282
2263
 
2283
2264
  // Validate file size
2284
2265
  if (file.size > maxAvatarSize) {
2285
- notifications.notifications.show({
2286
- title: labels.errorTitle || 'Erro',
2287
- message: labels.avatarTooLarge || `Imagem muito grande. Máximo ${Math.round(maxAvatarSize / 1024)}KB.`,
2288
- color: 'red'
2289
- });
2266
+ onError?.(new Error(labels.avatarTooLarge || `Imagem muito grande. Máximo ${Math.round(maxAvatarSize / 1024)}KB.`));
2290
2267
  return;
2291
2268
  }
2292
2269
  setAvatarFile(file);
@@ -2325,40 +2302,20 @@ function UserProfile({
2325
2302
  const handleChangePassword = async values => {
2326
2303
  try {
2327
2304
  await changePassword(values.currentPassword, values.newPassword);
2328
- notifications.notifications.show({
2329
- title: labels.successTitle || 'Sucesso',
2330
- message: labels.passwordChanged || 'Senha alterada com sucesso',
2331
- color: 'green'
2332
- });
2333
2305
  passwordForm.reset();
2334
2306
  setEditingSection(null);
2335
2307
  onPasswordChange?.();
2336
2308
  } catch (error) {
2337
- notifications.notifications.show({
2338
- title: labels.errorTitle || 'Erro',
2339
- message: error.message || labels.passwordChangeFailed || 'Falha ao alterar senha',
2340
- color: 'red'
2341
- });
2342
2309
  onError?.(error);
2343
2310
  }
2344
2311
  };
2345
2312
  const handleChangeEmail = async values => {
2346
2313
  try {
2347
2314
  await changeEmail(values.newEmail);
2348
- notifications.notifications.show({
2349
- title: labels.successTitle || 'Sucesso',
2350
- message: labels.emailVerificationSent || 'Verifique seu novo email para confirmar a alteração',
2351
- color: 'green'
2352
- });
2353
2315
  emailForm.reset();
2354
2316
  setEditingSection(null);
2355
2317
  onEmailChange?.(values.newEmail);
2356
2318
  } catch (error) {
2357
- notifications.notifications.show({
2358
- title: labels.errorTitle || 'Erro',
2359
- message: error.message || labels.emailChangeFailed || 'Falha ao alterar email',
2360
- color: 'red'
2361
- });
2362
2319
  onError?.(error);
2363
2320
  }
2364
2321
  };
@@ -2367,43 +2324,29 @@ function UserProfile({
2367
2324
  await updateProfile({
2368
2325
  name: values.name
2369
2326
  });
2370
- notifications.notifications.show({
2371
- title: labels.successTitle || 'Sucesso',
2372
- message: labels.nameUpdated || 'Nome atualizado com sucesso',
2373
- color: 'green'
2374
- });
2375
2327
  nameForm.reset();
2376
2328
  setEditingSection(null);
2377
2329
  onProfileUpdate?.({
2378
2330
  name: values.name
2379
2331
  });
2380
2332
  } catch (error) {
2381
- notifications.notifications.show({
2382
- title: labels.errorTitle || 'Erro',
2383
- message: error.message || labels.nameUpdateFailed || 'Falha ao atualizar nome',
2384
- color: 'red'
2385
- });
2386
2333
  onError?.(error);
2387
2334
  }
2388
2335
  };
2389
2336
  const handleChangeAvatar = async () => {
2390
2337
  if (!avatarPreview) {
2391
- notifications.notifications.show({
2392
- title: labels.errorTitle || 'Erro',
2393
- message: labels.avatarRequired || 'Selecione uma imagem',
2394
- color: 'red'
2395
- });
2338
+ // Optionally handle this validation error via callback or just return?
2339
+ // Since it's a validation error before async call, we might want to expose it too?
2340
+ // The original code used notifications. Let's send to onError for consistency or just return if it's UI state.
2341
+ // Actually, for validation within the component, maybe we can just let it be silent or use form error if applicable?
2342
+ // But this is outside form context. Let's use onError with a custom error object.
2343
+ onError?.(new Error(labels.avatarRequired || 'Selecione uma imagem'));
2396
2344
  return;
2397
2345
  }
2398
2346
  try {
2399
2347
  await updateProfile({
2400
2348
  image: avatarPreview
2401
2349
  });
2402
- notifications.notifications.show({
2403
- title: labels.successTitle || 'Sucesso',
2404
- message: labels.avatarUpdated || 'Foto de perfil atualizada com sucesso',
2405
- color: 'green'
2406
- });
2407
2350
  setAvatarPreview(null);
2408
2351
  setAvatarFile(null);
2409
2352
  setEditingSection(null);
@@ -2411,11 +2354,6 @@ function UserProfile({
2411
2354
  image: avatarPreview
2412
2355
  });
2413
2356
  } catch (error) {
2414
- notifications.notifications.show({
2415
- title: labels.errorTitle || 'Erro',
2416
- message: error.message || labels.avatarUpdateFailed || 'Falha ao atualizar foto',
2417
- color: 'red'
2418
- });
2419
2357
  onError?.(error);
2420
2358
  }
2421
2359
  };
@@ -2424,11 +2362,6 @@ function UserProfile({
2424
2362
  await updateProfile({
2425
2363
  image: ''
2426
2364
  });
2427
- notifications.notifications.show({
2428
- title: labels.successTitle || 'Sucesso',
2429
- message: labels.avatarRemoved || 'Foto de perfil removida',
2430
- color: 'green'
2431
- });
2432
2365
  setAvatarPreview(null);
2433
2366
  setAvatarFile(null);
2434
2367
  setEditingSection(null);
@@ -2436,11 +2369,6 @@ function UserProfile({
2436
2369
  image: ''
2437
2370
  });
2438
2371
  } catch (error) {
2439
- notifications.notifications.show({
2440
- title: labels.errorTitle || 'Erro',
2441
- message: error.message || labels.avatarRemoveFailed || 'Falha ao remover foto',
2442
- color: 'red'
2443
- });
2444
2372
  onError?.(error);
2445
2373
  }
2446
2374
  };