@umituz/react-native-auth 1.6.7 → 1.6.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-auth",
3
- "version": "1.6.7",
3
+ "version": "1.6.9",
4
4
  "description": "Authentication service for React Native apps - Secure, type-safe, and production-ready. Provider-agnostic design supports Firebase Auth and can be adapted for Supabase or other providers.",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -105,18 +105,34 @@ export const LoginForm: React.FC<LoginFormProps> = ({
105
105
  const handleContinueAsGuest = async () => {
106
106
  /* eslint-disable-next-line no-console */
107
107
  if (__DEV__) {
108
- console.log("[LoginForm] Continue as Guest button pressed");
108
+ console.log("========================================");
109
+ console.log("[LoginForm] 🎯 Continue as Guest button PRESSED");
110
+ console.log("[LoginForm] Current loading state:", loading);
111
+ console.log("[LoginForm] Current error state:", error);
112
+ console.log("========================================");
109
113
  }
114
+
110
115
  try {
116
+ /* eslint-disable-next-line no-console */
117
+ if (__DEV__) {
118
+ console.log("[LoginForm] Calling continueAsGuest() function...");
119
+ }
120
+
111
121
  await continueAsGuest();
122
+
112
123
  /* eslint-disable-next-line no-console */
113
124
  if (__DEV__) {
114
- console.log("[LoginForm] continueAsGuest completed");
125
+ console.log("[LoginForm] continueAsGuest() completed successfully");
126
+ console.log("[LoginForm] Current loading state after:", loading);
115
127
  }
116
128
  } catch (err) {
117
129
  /* eslint-disable-next-line no-console */
118
130
  if (__DEV__) {
119
- console.error("[LoginForm] Error in continueAsGuest:", err);
131
+ console.error("[LoginForm] ERROR in continueAsGuest:", err);
132
+ console.error("[LoginForm] Error details:", {
133
+ message: err instanceof Error ? err.message : String(err),
134
+ stack: err instanceof Error ? err.stack : undefined,
135
+ });
120
136
  }
121
137
  // Error handling is done in the hook
122
138
  }
@@ -173,10 +189,18 @@ export const LoginForm: React.FC<LoginFormProps> = ({
173
189
  <View style={styles.buttonContainer}>
174
190
  <AtomicButton
175
191
  variant="outline"
176
- onPress={handleContinueAsGuest}
192
+ onPress={() => {
193
+ /* eslint-disable-next-line no-console */
194
+ if (__DEV__) {
195
+ console.log("[LoginForm] 🔘 AtomicButton onPress triggered for Continue as Guest");
196
+ console.log("[LoginForm] Button disabled state:", loading);
197
+ }
198
+ handleContinueAsGuest();
199
+ }}
177
200
  disabled={loading}
178
201
  fullWidth
179
202
  style={styles.guestButton}
203
+ testID="continue-as-guest-button"
180
204
  >
181
205
  {t("auth.continueAsGuest")}
182
206
  </AtomicButton>
@@ -112,7 +112,7 @@ export function useAuth(): UseAuthResult {
112
112
 
113
113
  // Listen for guest-mode-enabled event to update state
114
114
  useEffect(() => {
115
- const subscription = DeviceEventEmitter.addListener(
115
+ const guestSubscription = DeviceEventEmitter.addListener(
116
116
  "guest-mode-enabled",
117
117
  () => {
118
118
  /* eslint-disable-next-line no-console */
@@ -123,10 +123,26 @@ export function useAuth(): UseAuthResult {
123
123
  }
124
124
  );
125
125
 
126
+ // Listen for user-authenticated event to ensure state updates
127
+ const authSubscription = DeviceEventEmitter.addListener(
128
+ "user-authenticated",
129
+ () => {
130
+ /* eslint-disable-next-line no-console */
131
+ if (__DEV__) {
132
+ console.log("[useAuth] User authenticated event received");
133
+ }
134
+ // Clear guest mode if set
135
+ if (isGuest) {
136
+ setIsGuest(false);
137
+ }
138
+ }
139
+ );
140
+
126
141
  return () => {
127
- subscription.remove();
142
+ guestSubscription.remove();
143
+ authSubscription.remove();
128
144
  };
129
- }, []);
145
+ }, [isGuest]);
130
146
 
131
147
  const signUp = useCallback(async (
132
148
  email: string,
@@ -219,41 +235,84 @@ export function useAuth(): UseAuthResult {
219
235
  const continueAsGuest = useCallback(async () => {
220
236
  /* eslint-disable-next-line no-console */
221
237
  if (__DEV__) {
222
- console.log("[useAuth] continueAsGuest called");
238
+ console.log("========================================");
239
+ console.log("[useAuth] 🎯 continueAsGuest() CALLED");
240
+ console.log("[useAuth] Current state:", {
241
+ isGuest,
242
+ loading,
243
+ firebaseUser: firebaseUser?.uid || null,
244
+ });
245
+ console.log("========================================");
223
246
  }
247
+
224
248
  const service = getAuthService();
225
249
  if (!service) {
226
250
  /* eslint-disable-next-line no-console */
227
251
  if (__DEV__) {
228
- console.log("[useAuth] No service, setting isGuest directly");
252
+ console.log("[useAuth] ⚠️ No service available, setting isGuest directly");
229
253
  }
230
254
  setIsGuest(true);
231
255
  return;
232
256
  }
257
+
233
258
  try {
259
+ /* eslint-disable-next-line no-console */
260
+ if (__DEV__) {
261
+ console.log("[useAuth] Setting loading to true...");
262
+ }
234
263
  setLoading(true);
264
+
235
265
  /* eslint-disable-next-line no-console */
236
266
  if (__DEV__) {
237
- console.log("[useAuth] Calling service.setGuestMode()");
267
+ console.log("[useAuth] 📞 Calling service.setGuestMode()...");
238
268
  }
239
269
  await service.setGuestMode();
270
+
240
271
  /* eslint-disable-next-line no-console */
241
272
  if (__DEV__) {
242
- console.log("[useAuth] Service.setGuestMode() completed, setting isGuest to true");
273
+ console.log("[useAuth] Service.setGuestMode() completed successfully");
274
+ console.log("[useAuth] Setting isGuest to true...");
243
275
  }
276
+
244
277
  // State will be updated by event listener, but set it here too for immediate update
245
278
  setIsGuest(true);
279
+
280
+ /* eslint-disable-next-line no-console */
281
+ if (__DEV__) {
282
+ console.log("[useAuth] ✅ isGuest set to true");
283
+ console.log("[useAuth] Current state after:", {
284
+ isGuest: true,
285
+ loading: true, // Still loading, will be set to false in finally
286
+ });
287
+ }
246
288
  } catch (error) {
247
289
  /* eslint-disable-next-line no-console */
248
290
  if (__DEV__) {
249
- console.error("[useAuth] Error in continueAsGuest:", error);
291
+ console.error("[useAuth] ERROR in continueAsGuest:", error);
292
+ console.error("[useAuth] Error details:", {
293
+ message: error instanceof Error ? error.message : String(error),
294
+ stack: error instanceof Error ? error.stack : undefined,
295
+ });
250
296
  }
251
297
  // Even if service fails, set guest mode locally
252
298
  setIsGuest(true);
253
299
  } finally {
300
+ /* eslint-disable-next-line no-console */
301
+ if (__DEV__) {
302
+ console.log("[useAuth] Setting loading to false...");
303
+ }
254
304
  setLoading(false);
305
+ /* eslint-disable-next-line no-console */
306
+ if (__DEV__) {
307
+ console.log("[useAuth] ✅ continueAsGuest() FINISHED");
308
+ console.log("[useAuth] Final state:", {
309
+ isGuest,
310
+ loading: false,
311
+ });
312
+ console.log("========================================");
313
+ }
255
314
  }
256
- }, []);
315
+ }, [isGuest, firebaseUser]);
257
316
 
258
317
  return {
259
318
  user,