@umituz/react-native-auth 1.6.4 → 1.6.6
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.
|
|
3
|
+
"version": "1.6.6",
|
|
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",
|
|
@@ -308,6 +308,10 @@ export class AuthService implements IAuthService {
|
|
|
308
308
|
* Set guest mode (no authentication)
|
|
309
309
|
*/
|
|
310
310
|
async setGuestMode(): Promise<void> {
|
|
311
|
+
/* eslint-disable-next-line no-console */
|
|
312
|
+
if (__DEV__) {
|
|
313
|
+
console.log("[AuthService] setGuestMode called");
|
|
314
|
+
}
|
|
311
315
|
const auth = this.getAuth();
|
|
312
316
|
|
|
313
317
|
// Sign out from Firebase if logged in
|
|
@@ -320,15 +324,31 @@ export class AuthService implements IAuthService {
|
|
|
320
324
|
}
|
|
321
325
|
|
|
322
326
|
this.isGuestMode = true;
|
|
327
|
+
/* eslint-disable-next-line no-console */
|
|
328
|
+
if (__DEV__) {
|
|
329
|
+
console.log("[AuthService] isGuestMode set to true");
|
|
330
|
+
}
|
|
323
331
|
|
|
324
332
|
// Persist guest mode to storage
|
|
325
333
|
try {
|
|
326
334
|
await storageRepository.setString(GUEST_MODE_KEY, "true");
|
|
335
|
+
/* eslint-disable-next-line no-console */
|
|
336
|
+
if (__DEV__) {
|
|
337
|
+
console.log("[AuthService] Guest mode persisted to storage");
|
|
338
|
+
}
|
|
327
339
|
} catch (error) {
|
|
328
340
|
// Ignore storage errors - guest mode will still work in memory
|
|
341
|
+
/* eslint-disable-next-line no-console */
|
|
342
|
+
if (__DEV__) {
|
|
343
|
+
console.warn("[AuthService] Failed to persist guest mode to storage:", error);
|
|
344
|
+
}
|
|
329
345
|
}
|
|
330
346
|
|
|
331
347
|
// Emit event for AppNavigator to handle navigation
|
|
348
|
+
/* eslint-disable-next-line no-console */
|
|
349
|
+
if (__DEV__) {
|
|
350
|
+
console.log("[AuthService] Emitting guest-mode-enabled event");
|
|
351
|
+
}
|
|
332
352
|
DeviceEventEmitter.emit("guest-mode-enabled");
|
|
333
353
|
}
|
|
334
354
|
|
|
@@ -81,9 +81,21 @@ export const LoginForm: React.FC<LoginFormProps> = ({
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
const handleContinueAsGuest = async () => {
|
|
84
|
+
/* eslint-disable-next-line no-console */
|
|
85
|
+
if (__DEV__) {
|
|
86
|
+
console.log("[LoginForm] Continue as Guest button pressed");
|
|
87
|
+
}
|
|
84
88
|
try {
|
|
85
89
|
await continueAsGuest();
|
|
90
|
+
/* eslint-disable-next-line no-console */
|
|
91
|
+
if (__DEV__) {
|
|
92
|
+
console.log("[LoginForm] continueAsGuest completed");
|
|
93
|
+
}
|
|
86
94
|
} catch (err) {
|
|
95
|
+
/* eslint-disable-next-line no-console */
|
|
96
|
+
if (__DEV__) {
|
|
97
|
+
console.error("[LoginForm] Error in continueAsGuest:", err);
|
|
98
|
+
}
|
|
87
99
|
// Error handling is done in the hook
|
|
88
100
|
}
|
|
89
101
|
};
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { useEffect, useRef, useCallback, useState } from "react";
|
|
10
10
|
import type { User } from "firebase/auth";
|
|
11
|
+
import { DeviceEventEmitter } from "react-native";
|
|
11
12
|
import { getAuthService } from "../../infrastructure/services/AuthService";
|
|
12
13
|
import { useFirebaseAuth } from "@umituz/react-native-firebase-auth";
|
|
13
14
|
|
|
@@ -109,6 +110,24 @@ export function useAuth(): UseAuthResult {
|
|
|
109
110
|
}
|
|
110
111
|
}, []);
|
|
111
112
|
|
|
113
|
+
// Listen for guest-mode-enabled event to update state
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
const subscription = DeviceEventEmitter.addListener(
|
|
116
|
+
"guest-mode-enabled",
|
|
117
|
+
() => {
|
|
118
|
+
/* eslint-disable-next-line no-console */
|
|
119
|
+
if (__DEV__) {
|
|
120
|
+
console.log("[useAuth] Guest mode enabled event received");
|
|
121
|
+
}
|
|
122
|
+
setIsGuest(true);
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
return () => {
|
|
127
|
+
subscription.remove();
|
|
128
|
+
};
|
|
129
|
+
}, []);
|
|
130
|
+
|
|
112
131
|
const signUp = useCallback(async (
|
|
113
132
|
email: string,
|
|
114
133
|
password: string,
|
|
@@ -178,14 +197,38 @@ export function useAuth(): UseAuthResult {
|
|
|
178
197
|
}, []);
|
|
179
198
|
|
|
180
199
|
const continueAsGuest = useCallback(async () => {
|
|
200
|
+
/* eslint-disable-next-line no-console */
|
|
201
|
+
if (__DEV__) {
|
|
202
|
+
console.log("[useAuth] continueAsGuest called");
|
|
203
|
+
}
|
|
181
204
|
const service = getAuthService();
|
|
182
205
|
if (!service) {
|
|
206
|
+
/* eslint-disable-next-line no-console */
|
|
207
|
+
if (__DEV__) {
|
|
208
|
+
console.log("[useAuth] No service, setting isGuest directly");
|
|
209
|
+
}
|
|
183
210
|
setIsGuest(true);
|
|
184
211
|
return;
|
|
185
212
|
}
|
|
186
213
|
try {
|
|
187
214
|
setLoading(true);
|
|
215
|
+
/* eslint-disable-next-line no-console */
|
|
216
|
+
if (__DEV__) {
|
|
217
|
+
console.log("[useAuth] Calling service.setGuestMode()");
|
|
218
|
+
}
|
|
188
219
|
await service.setGuestMode();
|
|
220
|
+
/* eslint-disable-next-line no-console */
|
|
221
|
+
if (__DEV__) {
|
|
222
|
+
console.log("[useAuth] Service.setGuestMode() completed, setting isGuest to true");
|
|
223
|
+
}
|
|
224
|
+
// State will be updated by event listener, but set it here too for immediate update
|
|
225
|
+
setIsGuest(true);
|
|
226
|
+
} catch (error) {
|
|
227
|
+
/* eslint-disable-next-line no-console */
|
|
228
|
+
if (__DEV__) {
|
|
229
|
+
console.error("[useAuth] Error in continueAsGuest:", error);
|
|
230
|
+
}
|
|
231
|
+
// Even if service fails, set guest mode locally
|
|
189
232
|
setIsGuest(true);
|
|
190
233
|
} finally {
|
|
191
234
|
setLoading(false);
|