@umituz/react-native-auth 1.6.6 → 1.6.7
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.7",
|
|
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",
|
|
@@ -238,6 +238,10 @@ export class AuthService implements IAuthService {
|
|
|
238
238
|
* Sign in an existing user
|
|
239
239
|
*/
|
|
240
240
|
async signIn(params: SignInParams): Promise<User> {
|
|
241
|
+
/* eslint-disable-next-line no-console */
|
|
242
|
+
if (__DEV__) {
|
|
243
|
+
console.log("[AuthService] signIn called with email:", params.email);
|
|
244
|
+
}
|
|
241
245
|
const auth = this.getAuth();
|
|
242
246
|
if (!auth) {
|
|
243
247
|
throw new AuthInitializationError("Auth service is not initialized");
|
|
@@ -254,27 +258,48 @@ export class AuthService implements IAuthService {
|
|
|
254
258
|
}
|
|
255
259
|
|
|
256
260
|
try {
|
|
261
|
+
/* eslint-disable-next-line no-console */
|
|
262
|
+
if (__DEV__) {
|
|
263
|
+
console.log("[AuthService] Calling signInWithEmailAndPassword");
|
|
264
|
+
}
|
|
257
265
|
const userCredential = await signInWithEmailAndPassword(
|
|
258
266
|
auth,
|
|
259
267
|
params.email.trim(),
|
|
260
268
|
params.password
|
|
261
269
|
);
|
|
262
270
|
|
|
271
|
+
/* eslint-disable-next-line no-console */
|
|
272
|
+
if (__DEV__) {
|
|
273
|
+
console.log("[AuthService] signInWithEmailAndPassword successful, user:", userCredential.user.uid);
|
|
274
|
+
}
|
|
275
|
+
|
|
263
276
|
// Clear guest mode when user signs in
|
|
264
277
|
if (this.isGuestMode) {
|
|
265
278
|
this.isGuestMode = false;
|
|
266
279
|
try {
|
|
267
280
|
await storageRepository.removeItem(GUEST_MODE_KEY);
|
|
281
|
+
/* eslint-disable-next-line no-console */
|
|
282
|
+
if (__DEV__) {
|
|
283
|
+
console.log("[AuthService] Guest mode cleared from storage");
|
|
284
|
+
}
|
|
268
285
|
} catch (error) {
|
|
269
286
|
// Ignore storage errors
|
|
270
287
|
}
|
|
271
288
|
}
|
|
272
289
|
|
|
273
290
|
// Emit event for AppNavigator to handle navigation
|
|
291
|
+
/* eslint-disable-next-line no-console */
|
|
292
|
+
if (__DEV__) {
|
|
293
|
+
console.log("[AuthService] Emitting user-authenticated event");
|
|
294
|
+
}
|
|
274
295
|
DeviceEventEmitter.emit("user-authenticated", { userId: userCredential.user.uid });
|
|
275
296
|
|
|
276
297
|
return userCredential.user;
|
|
277
298
|
} catch (error: any) {
|
|
299
|
+
/* eslint-disable-next-line no-console */
|
|
300
|
+
if (__DEV__) {
|
|
301
|
+
console.error("[AuthService] signIn error:", error);
|
|
302
|
+
}
|
|
278
303
|
throw mapFirebaseAuthError(error);
|
|
279
304
|
}
|
|
280
305
|
}
|
|
@@ -47,6 +47,10 @@ export const LoginForm: React.FC<LoginFormProps> = ({
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
const handleSignIn = async () => {
|
|
50
|
+
/* eslint-disable-next-line no-console */
|
|
51
|
+
if (__DEV__) {
|
|
52
|
+
console.log("[LoginForm] handleSignIn called");
|
|
53
|
+
}
|
|
50
54
|
setEmailError(null);
|
|
51
55
|
setPasswordError(null);
|
|
52
56
|
setLocalError(null);
|
|
@@ -69,11 +73,29 @@ export const LoginForm: React.FC<LoginFormProps> = ({
|
|
|
69
73
|
hasError = true;
|
|
70
74
|
}
|
|
71
75
|
|
|
72
|
-
if (hasError)
|
|
76
|
+
if (hasError) {
|
|
77
|
+
/* eslint-disable-next-line no-console */
|
|
78
|
+
if (__DEV__) {
|
|
79
|
+
console.log("[LoginForm] Validation errors, returning early");
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
73
83
|
|
|
74
84
|
try {
|
|
85
|
+
/* eslint-disable-next-line no-console */
|
|
86
|
+
if (__DEV__) {
|
|
87
|
+
console.log("[LoginForm] Calling signIn with email:", email.trim());
|
|
88
|
+
}
|
|
75
89
|
await signIn(email.trim(), password);
|
|
90
|
+
/* eslint-disable-next-line no-console */
|
|
91
|
+
if (__DEV__) {
|
|
92
|
+
console.log("[LoginForm] signIn completed successfully");
|
|
93
|
+
}
|
|
76
94
|
} catch (err: any) {
|
|
95
|
+
/* eslint-disable-next-line no-console */
|
|
96
|
+
if (__DEV__) {
|
|
97
|
+
console.error("[LoginForm] signIn error:", err);
|
|
98
|
+
}
|
|
77
99
|
const localizationKey = getAuthErrorLocalizationKey(err);
|
|
78
100
|
const errorMessage = t(localizationKey);
|
|
79
101
|
setLocalError(errorMessage);
|
|
@@ -158,6 +158,10 @@ export function useAuth(): UseAuthResult {
|
|
|
158
158
|
}, [isGuest]);
|
|
159
159
|
|
|
160
160
|
const signIn = useCallback(async (email: string, password: string) => {
|
|
161
|
+
/* eslint-disable-next-line no-console */
|
|
162
|
+
if (__DEV__) {
|
|
163
|
+
console.log("[useAuth] signIn called with email:", email);
|
|
164
|
+
}
|
|
161
165
|
const service = getAuthService();
|
|
162
166
|
if (!service) {
|
|
163
167
|
const err = "Auth service is not initialized";
|
|
@@ -167,13 +171,29 @@ export function useAuth(): UseAuthResult {
|
|
|
167
171
|
try {
|
|
168
172
|
setLoading(true);
|
|
169
173
|
setError(null);
|
|
174
|
+
/* eslint-disable-next-line no-console */
|
|
175
|
+
if (__DEV__) {
|
|
176
|
+
console.log("[useAuth] Calling service.signIn()");
|
|
177
|
+
}
|
|
170
178
|
await service.signIn({ email, password });
|
|
179
|
+
/* eslint-disable-next-line no-console */
|
|
180
|
+
if (__DEV__) {
|
|
181
|
+
console.log("[useAuth] Service.signIn() completed successfully");
|
|
182
|
+
}
|
|
171
183
|
// Clear guest mode when user signs in
|
|
172
184
|
if (isGuest) {
|
|
185
|
+
/* eslint-disable-next-line no-console */
|
|
186
|
+
if (__DEV__) {
|
|
187
|
+
console.log("[useAuth] Clearing guest mode after sign in");
|
|
188
|
+
}
|
|
173
189
|
setIsGuest(false);
|
|
174
190
|
}
|
|
175
191
|
// User state is updated by Firebase Auth's onAuthStateChanged
|
|
176
192
|
} catch (err: any) {
|
|
193
|
+
/* eslint-disable-next-line no-console */
|
|
194
|
+
if (__DEV__) {
|
|
195
|
+
console.error("[useAuth] Error in signIn:", err);
|
|
196
|
+
}
|
|
177
197
|
const errorMessage = err.message || "Failed to sign in";
|
|
178
198
|
setError(errorMessage);
|
|
179
199
|
throw err;
|