@umituz/react-native-auth 4.1.3 → 4.2.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-auth",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Authentication service for React Native apps - Secure, type-safe, and production-ready. Provider-agnostic design with dependency injection, configurable validation, and comprehensive error handling.",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { useCallback, useState } from "react";
|
|
7
7
|
import { useAuth } from "./useAuth";
|
|
8
|
-
import { deleteCurrentUser
|
|
8
|
+
import { deleteCurrentUser } from "@umituz/react-native-firebase";
|
|
9
9
|
|
|
10
10
|
export interface UseAccountManagementOptions {
|
|
11
11
|
/**
|
|
@@ -15,16 +15,9 @@ export interface UseAccountManagementOptions {
|
|
|
15
15
|
onReauthRequired?: () => Promise<string | null>;
|
|
16
16
|
/**
|
|
17
17
|
* Callback invoked when password reauthentication is required
|
|
18
|
-
*
|
|
18
|
+
* Required for password-based accounts
|
|
19
19
|
*/
|
|
20
20
|
onPasswordRequired?: () => Promise<string | null>;
|
|
21
|
-
/**
|
|
22
|
-
* Translations for built-in password prompt
|
|
23
|
-
*/
|
|
24
|
-
passwordPromptTitle?: string;
|
|
25
|
-
passwordPromptMessage?: string;
|
|
26
|
-
passwordPromptCancel?: string;
|
|
27
|
-
passwordPromptConfirm?: string;
|
|
28
21
|
}
|
|
29
22
|
|
|
30
23
|
export interface UseAccountManagementReturn {
|
|
@@ -32,7 +25,6 @@ export interface UseAccountManagementReturn {
|
|
|
32
25
|
deleteAccount: () => Promise<void>;
|
|
33
26
|
isLoading: boolean;
|
|
34
27
|
isDeletingAccount: boolean;
|
|
35
|
-
PasswordPromptComponent: React.ReactNode;
|
|
36
28
|
}
|
|
37
29
|
|
|
38
30
|
export const useAccountManagement = (
|
|
@@ -41,30 +33,13 @@ export const useAccountManagement = (
|
|
|
41
33
|
const { user, loading, signOut } = useAuth();
|
|
42
34
|
const [isDeletingAccount, setIsDeletingAccount] = useState(false);
|
|
43
35
|
|
|
44
|
-
const {
|
|
45
|
-
onReauthRequired,
|
|
46
|
-
onPasswordRequired,
|
|
47
|
-
passwordPromptTitle = "Password Required",
|
|
48
|
-
passwordPromptMessage = "Enter your password to delete account",
|
|
49
|
-
passwordPromptCancel = "Cancel",
|
|
50
|
-
passwordPromptConfirm = "Confirm",
|
|
51
|
-
} = options;
|
|
52
|
-
|
|
53
|
-
const { showPasswordPrompt, PasswordPromptComponent } = usePasswordPrompt({
|
|
54
|
-
title: passwordPromptTitle,
|
|
55
|
-
message: passwordPromptMessage,
|
|
56
|
-
cancelText: passwordPromptCancel,
|
|
57
|
-
confirmText: passwordPromptConfirm,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const passwordHandler = onPasswordRequired || showPasswordPrompt;
|
|
36
|
+
const { onReauthRequired, onPasswordRequired } = options;
|
|
61
37
|
|
|
62
38
|
const logout = useCallback(async () => {
|
|
63
39
|
await signOut();
|
|
64
40
|
}, [signOut]);
|
|
65
41
|
|
|
66
42
|
const deleteAccount = useCallback(async () => {
|
|
67
|
-
console.log("[useAccountManagement] deleteAccount called", { user: user?.uid });
|
|
68
43
|
if (!user) {
|
|
69
44
|
throw new Error("No user logged in");
|
|
70
45
|
}
|
|
@@ -76,28 +51,24 @@ export const useAccountManagement = (
|
|
|
76
51
|
setIsDeletingAccount(true);
|
|
77
52
|
|
|
78
53
|
try {
|
|
79
|
-
console.log("[useAccountManagement] Calling deleteCurrentUser...");
|
|
80
54
|
const result = await deleteCurrentUser({
|
|
81
55
|
autoReauthenticate: true,
|
|
82
|
-
onPasswordRequired
|
|
56
|
+
onPasswordRequired,
|
|
83
57
|
onGoogleReauthRequired: onReauthRequired,
|
|
84
58
|
});
|
|
85
59
|
|
|
86
|
-
console.log("[useAccountManagement] deleteCurrentUser result:", result);
|
|
87
|
-
|
|
88
60
|
if (!result.success) {
|
|
89
61
|
throw new Error(result.error?.message || "Failed to delete account");
|
|
90
62
|
}
|
|
91
63
|
} finally {
|
|
92
64
|
setIsDeletingAccount(false);
|
|
93
65
|
}
|
|
94
|
-
}, [user,
|
|
66
|
+
}, [user, onPasswordRequired, onReauthRequired]);
|
|
95
67
|
|
|
96
68
|
return {
|
|
97
69
|
logout,
|
|
98
70
|
deleteAccount,
|
|
99
71
|
isLoading: loading,
|
|
100
72
|
isDeletingAccount,
|
|
101
|
-
PasswordPromptComponent,
|
|
102
73
|
};
|
|
103
74
|
};
|