@umituz/react-native-auth 3.4.32 → 3.4.33
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/README.md +347 -348
- package/package.json +2 -3
- package/src/index.ts +35 -0
- package/src/infrastructure/utils/validation/BaseValidators.ts +35 -0
- package/src/infrastructure/utils/validation/CollectionValidators.ts +56 -0
- package/src/infrastructure/utils/validation/DateValidators.ts +63 -0
- package/src/infrastructure/utils/validation/FormValidators.ts +22 -0
- package/src/infrastructure/utils/validation/NumberValidators.ts +55 -0
- package/src/infrastructure/utils/validation/StringValidators.ts +55 -0
- package/src/infrastructure/utils/validation/sanitization.ts +98 -0
- package/src/infrastructure/utils/validation/types.ts +15 -0
- package/src/presentation/components/ProfileComponents.md +307 -504
- package/src/presentation/hooks/useAccountManagement.md +295 -344
- package/src/presentation/hooks/useAuth.md +271 -227
- package/src/presentation/hooks/useAuthBottomSheet.md +417 -367
- package/src/presentation/hooks/useAuthRequired.md +308 -194
- package/src/presentation/hooks/useProfileUpdate.md +251 -279
- package/src/presentation/hooks/useSocialLogin.md +312 -287
- package/src/presentation/hooks/useUserProfile.md +259 -192
|
@@ -2,385 +2,336 @@
|
|
|
2
2
|
|
|
3
3
|
Hook for account management operations (logout, delete account).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- Account deletion with reauthentication
|
|
9
|
-
- Reauthentication callback support
|
|
10
|
-
- Loading state management
|
|
7
|
+
## Strategy
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
**Purpose**: Provides safe account management operations including sign out and account deletion with proper confirmations and reauthentication.
|
|
13
10
|
|
|
11
|
+
**When to Use**:
|
|
12
|
+
- Account settings screens
|
|
13
|
+
- Logout functionality
|
|
14
|
+
- Account deletion flows
|
|
15
|
+
- Need user account operations
|
|
16
|
+
|
|
17
|
+
**Import Path**:
|
|
14
18
|
```typescript
|
|
15
19
|
import { useAccountManagement } from '@umituz/react-native-auth';
|
|
16
|
-
|
|
17
|
-
function AccountSettings() {
|
|
18
|
-
const { logout, deleteAccount, isLoading, isDeletingAccount } = useAccountManagement({
|
|
19
|
-
onReauthRequired: async () => {
|
|
20
|
-
// Show Google/Apple sign-in UI
|
|
21
|
-
const result = await reauthenticateWithGoogle();
|
|
22
|
-
return result.success;
|
|
23
|
-
},
|
|
24
|
-
onPasswordRequired: async () => {
|
|
25
|
-
// Show password prompt
|
|
26
|
-
const password = await showPasswordPrompt();
|
|
27
|
-
return password;
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<View>
|
|
33
|
-
<Button onPress={logout}>Sign Out</Button>
|
|
34
|
-
<Button onPress={deleteAccount}>Delete Account</Button>
|
|
35
|
-
</View>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
20
|
```
|
|
39
21
|
|
|
40
|
-
|
|
22
|
+
**Hook Location**: `src/presentation/hooks/useAccountManagement.ts`
|
|
41
23
|
|
|
42
|
-
|
|
24
|
+
---
|
|
43
25
|
|
|
44
|
-
|
|
45
|
-
|-------|------|----------|-------------|
|
|
46
|
-
| `onReauthRequired` | `() => Promise<boolean>` | No | Callback for Google/Apple reauthentication |
|
|
47
|
-
| `onPasswordRequired` | `() => Promise<string \| null>` | No | Callback for password reauthentication |
|
|
26
|
+
## Core Operations
|
|
48
27
|
|
|
49
|
-
###
|
|
28
|
+
### logout
|
|
50
29
|
|
|
51
|
-
|
|
52
|
-
|------|------|-------------|
|
|
53
|
-
| `logout` | `() => Promise<void>` | Sign out function |
|
|
54
|
-
| `deleteAccount` | `() => Promise<void>` | Delete account function |
|
|
55
|
-
| `isLoading` | `boolean` | General loading state |
|
|
56
|
-
| `isDeletingAccount` | `boolean` | Account deletion loading state |
|
|
30
|
+
**Purpose**: Sign out user and clear authentication state.
|
|
57
31
|
|
|
58
|
-
|
|
32
|
+
**Rules**:
|
|
33
|
+
- MUST confirm with user before signing out
|
|
34
|
+
- MUST handle loading state during operation
|
|
35
|
+
- MUST clear local user data after sign out
|
|
36
|
+
- MUST navigate to login screen after sign out
|
|
37
|
+
- MUST handle errors gracefully
|
|
59
38
|
|
|
60
|
-
|
|
39
|
+
**MUST NOT**:
|
|
40
|
+
- Sign out without user confirmation
|
|
41
|
+
- Clear user data before sign out complete
|
|
42
|
+
- Block app functionality on error
|
|
43
|
+
- Lose navigation context
|
|
61
44
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
<Section title="Session">
|
|
69
|
-
<MenuItem
|
|
70
|
-
title="Sign Out"
|
|
71
|
-
icon="log-out"
|
|
72
|
-
onPress={logout}
|
|
73
|
-
/>
|
|
74
|
-
</Section>
|
|
75
|
-
|
|
76
|
-
<Section title="Danger Zone">
|
|
77
|
-
<MenuItem
|
|
78
|
-
title="Delete Account"
|
|
79
|
-
icon="trash"
|
|
80
|
-
onPress={deleteAccount}
|
|
81
|
-
destructive
|
|
82
|
-
disabled={isDeletingAccount}
|
|
83
|
-
/>
|
|
84
|
-
{isDeletingAccount && <ActivityIndicator />}
|
|
85
|
-
</Section>
|
|
86
|
-
</ScrollView>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
```
|
|
45
|
+
**Constraints**:
|
|
46
|
+
- Clears Firebase Auth session
|
|
47
|
+
- Resets auth store state
|
|
48
|
+
- Anonymous users: Loses all data
|
|
49
|
+
- Authenticated users: Can sign back in
|
|
50
|
+
- No server-side data deletion
|
|
90
51
|
|
|
91
|
-
|
|
52
|
+
---
|
|
92
53
|
|
|
93
|
-
|
|
94
|
-
function AccountSettingsScreen() {
|
|
95
|
-
const { logout, deleteAccount } = useAccountManagement({
|
|
96
|
-
onReauthRequired: async () => {
|
|
97
|
-
try {
|
|
98
|
-
// Reauthenticate with Google
|
|
99
|
-
const result = await signInWithGooglePopup();
|
|
100
|
-
|
|
101
|
-
if (result.user) {
|
|
102
|
-
Alert.alert('Success', 'Please continue with account deletion');
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return false;
|
|
107
|
-
} catch (error) {
|
|
108
|
-
Alert.alert('Error', 'Reauthentication failed');
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
onPasswordRequired: async () => {
|
|
113
|
-
return new Promise((resolve) => {
|
|
114
|
-
// Show password prompt
|
|
115
|
-
Alert.prompt(
|
|
116
|
-
'Enter Password',
|
|
117
|
-
'Please enter your password to delete your account',
|
|
118
|
-
[
|
|
119
|
-
{
|
|
120
|
-
text: 'Cancel',
|
|
121
|
-
onPress: () => resolve(null),
|
|
122
|
-
style: 'cancel',
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
text: 'OK',
|
|
126
|
-
onPress: (password) => resolve(password || null),
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
'secure-text'
|
|
130
|
-
);
|
|
131
|
-
});
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
// ...
|
|
136
|
-
}
|
|
137
|
-
```
|
|
54
|
+
### deleteAccount
|
|
138
55
|
|
|
139
|
-
|
|
56
|
+
**Purpose**: Permanently delete user account and all associated data.
|
|
140
57
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return new Promise((resolve) => {
|
|
149
|
-
// Custom reauthentication UI
|
|
150
|
-
const handleResult = (success: boolean) => {
|
|
151
|
-
setShowReauth(false);
|
|
152
|
-
resolve(success);
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
showCustomReauthUI(handleResult);
|
|
156
|
-
});
|
|
157
|
-
},
|
|
158
|
-
onPasswordRequired: async () => {
|
|
159
|
-
setShowReauth(true);
|
|
160
|
-
return new Promise((resolve) => {
|
|
161
|
-
// Custom password prompt
|
|
162
|
-
showPasswordPrompt((password) => {
|
|
163
|
-
setShowReauth(false);
|
|
164
|
-
resolve(password);
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
},
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
const handleDelete = async () => {
|
|
171
|
-
try {
|
|
172
|
-
await deleteAccount();
|
|
173
|
-
Alert.alert('Success', 'Account deleted');
|
|
174
|
-
} catch (error) {
|
|
175
|
-
Alert.alert('Error', error.message);
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
return (
|
|
180
|
-
<View>
|
|
181
|
-
<Button onPress={handleDelete} disabled={isDeletingAccount}>
|
|
182
|
-
Delete Account
|
|
183
|
-
</Button>
|
|
184
|
-
|
|
185
|
-
{showReauth && (
|
|
186
|
-
<ReauthenticationModal
|
|
187
|
-
onComplete={() => {
|
|
188
|
-
// Reauthentication successful, deleteAccount continues
|
|
189
|
-
}}
|
|
190
|
-
/>
|
|
191
|
-
)}
|
|
192
|
-
</View>
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
```
|
|
58
|
+
**Rules**:
|
|
59
|
+
- MUST require double confirmation
|
|
60
|
+
- MUST show clear warning about irreversibility
|
|
61
|
+
- MUST require recent authentication
|
|
62
|
+
- MUST handle reauthentication if needed
|
|
63
|
+
- MUST provide error messages on failure
|
|
64
|
+
- MUST hide option for anonymous users
|
|
196
65
|
|
|
197
|
-
|
|
66
|
+
**MUST NOT**:
|
|
67
|
+
- Delete account without confirmation
|
|
68
|
+
- Delete without recent authentication
|
|
69
|
+
- Show to anonymous users
|
|
70
|
+
- Expose technical error details
|
|
71
|
+
- Allow account recovery
|
|
198
72
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if (!agreed) {
|
|
206
|
-
Alert.alert('Warning', 'Please accept the terms');
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
Alert.alert(
|
|
211
|
-
'Delete Account',
|
|
212
|
-
'This action cannot be undone. Are you sure?',
|
|
213
|
-
[
|
|
214
|
-
{ text: 'Cancel', style: 'cancel' },
|
|
215
|
-
{
|
|
216
|
-
text: 'Delete',
|
|
217
|
-
style: 'destructive',
|
|
218
|
-
onPress: deleteAccount,
|
|
219
|
-
},
|
|
220
|
-
]
|
|
221
|
-
);
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
return (
|
|
225
|
-
<View>
|
|
226
|
-
<Text style={styles.warning}>
|
|
227
|
-
By deleting your account:
|
|
228
|
-
</Text>
|
|
229
|
-
<Text>• All your data will be permanently deleted</Text>
|
|
230
|
-
<Text>• This action cannot be undone</Text>
|
|
231
|
-
<Text>• You won't be able to sign in with the same account</Text>
|
|
232
|
-
|
|
233
|
-
<CheckBox
|
|
234
|
-
value={agreed}
|
|
235
|
-
onValueChange={setAgreed}
|
|
236
|
-
label="I accept the account deletion terms"
|
|
237
|
-
/>
|
|
238
|
-
|
|
239
|
-
<Button
|
|
240
|
-
onPress={handleDelete}
|
|
241
|
-
disabled={!agreed || isDeletingAccount}
|
|
242
|
-
style={{ backgroundColor: 'red' }}
|
|
243
|
-
>
|
|
244
|
-
{isDeletingAccount ? 'Deleting...' : 'Permanently Delete Account'}
|
|
245
|
-
</Button>
|
|
246
|
-
</View>
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
```
|
|
73
|
+
**Constraints**:
|
|
74
|
+
- Firebase requirement: Recent authentication (< 5 minutes)
|
|
75
|
+
- Double confirmation: Warning + Confirm
|
|
76
|
+
- Permanent deletion: Cannot undo
|
|
77
|
+
- Reauthentication: May be required
|
|
78
|
+
- Anonymous accounts: Cannot be deleted
|
|
250
79
|
|
|
251
|
-
|
|
80
|
+
---
|
|
252
81
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
82
|
+
## Reauthentication
|
|
83
|
+
|
|
84
|
+
### Strategy
|
|
85
|
+
|
|
86
|
+
**Purpose**: Handle Firebase requirement for recent authentication before sensitive operations.
|
|
87
|
+
|
|
88
|
+
**Rules**:
|
|
89
|
+
- MUST provide reauthentication callbacks
|
|
90
|
+
- MUST support both password and social auth reauth
|
|
91
|
+
- MUST show reauthentication UI when required
|
|
92
|
+
- MUST block operation until reauth complete
|
|
93
|
+
- MUST handle reauth failure gracefully
|
|
94
|
+
|
|
95
|
+
**MUST NOT**:
|
|
96
|
+
- Skip reauthentication requirement
|
|
97
|
+
- Allow operation without recent auth
|
|
98
|
+
- Hide reauthentication prompt from user
|
|
99
|
+
- Confuse reauth with initial login
|
|
100
|
+
|
|
101
|
+
### Constraints
|
|
102
|
+
|
|
103
|
+
**REAUTHENTICATION TRIGGERS**:
|
|
104
|
+
- Account deletion
|
|
105
|
+
- Password change (if implementing)
|
|
106
|
+
- Sensitive account operations
|
|
107
|
+
- Firebase-determined requirement
|
|
108
|
+
|
|
109
|
+
**CALLBACK TYPES**:
|
|
110
|
+
|
|
111
|
+
**onReauthRequired**
|
|
112
|
+
- Used for: Google/Apple social auth users
|
|
113
|
+
- Purpose: Re-sign in with social provider
|
|
114
|
+
- Must return: `boolean` (success status)
|
|
115
|
+
- Called when: Social auth needs reauth
|
|
116
|
+
|
|
117
|
+
**onPasswordRequired**
|
|
118
|
+
- Used for: Email/password users
|
|
119
|
+
- Purpose: Get current password
|
|
120
|
+
- Must return: `string | null` (password or cancel)
|
|
121
|
+
- Called when: Email auth needs reauth
|
|
122
|
+
|
|
123
|
+
**REAUTH FLOW**:
|
|
124
|
+
1. User initiates sensitive operation
|
|
125
|
+
2. Firebase requires recent authentication
|
|
126
|
+
3. Hook calls appropriate callback
|
|
127
|
+
4. App shows reauthentication UI
|
|
128
|
+
5. User reauthenticates
|
|
129
|
+
6. Operation proceeds if successful
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Loading States
|
|
134
|
+
|
|
135
|
+
### Strategy
|
|
136
|
+
|
|
137
|
+
**Purpose**: Proper UX during account management operations.
|
|
138
|
+
|
|
139
|
+
**Rules**:
|
|
140
|
+
- MUST show loading indicator during operations
|
|
141
|
+
- MUST disable buttons during operation
|
|
142
|
+
- MUST prevent concurrent operations
|
|
143
|
+
- MUST re-enable after completion
|
|
144
|
+
|
|
145
|
+
**MUST NOT**:
|
|
146
|
+
- Allow multiple simultaneous operations
|
|
147
|
+
- Leave loading state indefinitely
|
|
148
|
+
- Block UI without indication
|
|
149
|
+
- Allow operation during loading
|
|
150
|
+
|
|
151
|
+
### Constraints
|
|
152
|
+
|
|
153
|
+
**LOADING STATES**:
|
|
154
|
+
- `isLoading: boolean` - General loading state
|
|
155
|
+
- `isDeletingAccount: boolean` - Specific to deletion
|
|
156
|
+
|
|
157
|
+
**OPERATION DURATION**:
|
|
158
|
+
- Sign out: < 2 seconds
|
|
159
|
+
- Account deletion: 5-10 seconds
|
|
160
|
+
- Reauthentication: Variable (user-controlled)
|
|
161
|
+
|
|
162
|
+
**DISABLED STATES**:
|
|
163
|
+
- Disable all account actions during operation
|
|
164
|
+
- Disable navigation during operation
|
|
165
|
+
- Show progress indication
|
|
166
|
+
- Maintain interactivity for cancel
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Anonymous User Handling
|
|
171
|
+
|
|
172
|
+
### Strategy
|
|
173
|
+
|
|
174
|
+
**Purpose**: Proper handling for anonymous users vs authenticated users.
|
|
175
|
+
|
|
176
|
+
**Rules**:
|
|
177
|
+
- MUST hide account deletion for anonymous users
|
|
178
|
+
- MUST show "Create Account" option instead
|
|
179
|
+
- MUST explain anonymous limitations
|
|
180
|
+
- MUST preserve data during upgrade
|
|
181
|
+
|
|
182
|
+
**MUST NOT**:
|
|
183
|
+
- Show account deletion to anonymous users
|
|
184
|
+
- Allow sign out without warning
|
|
185
|
+
- Treat anonymous users as authenticated
|
|
186
|
+
- Hide anonymous status
|
|
187
|
+
|
|
188
|
+
### Constraints
|
|
189
|
+
|
|
190
|
+
**ANONYMOUS LIMITATIONS**:
|
|
191
|
+
- Cannot delete anonymous account
|
|
192
|
+
- Cannot change password (no password)
|
|
193
|
+
- Sign out loses all data
|
|
194
|
+
- Limited account settings
|
|
195
|
+
|
|
196
|
+
**UPGRADE PATH**:
|
|
197
|
+
- Anonymous → Registered
|
|
198
|
+
- Link credentials to anonymous account
|
|
199
|
+
- Preserve existing user ID
|
|
200
|
+
- Migrate existing data
|
|
201
|
+
- Seamless transition
|
|
202
|
+
|
|
203
|
+
---
|
|
279
204
|
|
|
280
205
|
## Error Handling
|
|
281
206
|
|
|
282
|
-
|
|
283
|
-
function AccountSettingsWithErrorHandling() {
|
|
284
|
-
const { logout, deleteAccount } = useAccountManagement();
|
|
285
|
-
const navigation = useNavigation();
|
|
286
|
-
|
|
287
|
-
const handleLogout = async () => {
|
|
288
|
-
try {
|
|
289
|
-
await logout();
|
|
290
|
-
navigation.replace('Login');
|
|
291
|
-
} catch (error) {
|
|
292
|
-
if (error.code === 'auth/network-request-failed') {
|
|
293
|
-
Alert.alert('Connection Error', 'Check your internet connection');
|
|
294
|
-
} else {
|
|
295
|
-
Alert.alert('Error', 'Failed to sign out');
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
const handleDeleteAccount = async () => {
|
|
301
|
-
try {
|
|
302
|
-
await deleteAccount();
|
|
303
|
-
Alert.alert('Success', 'Account deleted');
|
|
304
|
-
navigation.replace('Login');
|
|
305
|
-
} catch (error) {
|
|
306
|
-
if (error.code === 'auth/requires-recent-login') {
|
|
307
|
-
Alert.alert(
|
|
308
|
-
'Authentication Required',
|
|
309
|
-
'Please sign in again to delete your account'
|
|
310
|
-
);
|
|
311
|
-
} else if (error.code === 'auth/too-many-requests') {
|
|
312
|
-
Alert.alert(
|
|
313
|
-
'Too Many Attempts',
|
|
314
|
-
'Too many failed attempts. Please try again later'
|
|
315
|
-
);
|
|
316
|
-
} else {
|
|
317
|
-
Alert.alert('Error', 'Failed to delete account');
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
return (
|
|
323
|
-
<View>
|
|
324
|
-
<Button onPress={handleLogout}>Sign Out</Button>
|
|
325
|
-
<Button onPress={handleDeleteAccount}>Delete Account</Button>
|
|
326
|
-
</View>
|
|
327
|
-
);
|
|
328
|
-
}
|
|
329
|
-
```
|
|
207
|
+
### Strategy
|
|
330
208
|
|
|
331
|
-
|
|
209
|
+
**Purpose**: Graceful handling of account operation failures.
|
|
332
210
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
211
|
+
**Rules**:
|
|
212
|
+
- MUST handle operation errors gracefully
|
|
213
|
+
- MUST show user-friendly error messages
|
|
214
|
+
- MUST allow retry after failures
|
|
215
|
+
- MUST not crash on errors
|
|
216
|
+
- MUST distinguish error types
|
|
217
|
+
|
|
218
|
+
**MUST NOT**:
|
|
219
|
+
- Show raw error messages to users
|
|
220
|
+
- Block retry indefinitely
|
|
221
|
+
- Crash on operation failures
|
|
222
|
+
- Expose sensitive error details
|
|
223
|
+
|
|
224
|
+
### Constraints
|
|
225
|
+
|
|
226
|
+
**ERROR CATEGORIES**:
|
|
227
|
+
- Network errors: Connection issues
|
|
228
|
+
- Reauth errors: Authentication required
|
|
229
|
+
- Permission errors: Insufficient permissions
|
|
230
|
+
- Firebase errors: Service issues
|
|
337
231
|
|
|
338
|
-
|
|
232
|
+
**RECOVERY OPTIONS**:
|
|
233
|
+
- Retry operation automatically
|
|
234
|
+
- Show error with retry button
|
|
235
|
+
- Reauthenticate if required
|
|
236
|
+
- Support contact for persistent issues
|
|
339
237
|
|
|
340
|
-
|
|
238
|
+
**ERROR DISPLAY**:
|
|
239
|
+
- Alert/Modal for critical errors
|
|
240
|
+
- Inline text for non-critical
|
|
241
|
+
- Toast for success/cancellation
|
|
242
|
+
- Console logging for debugging
|
|
341
243
|
|
|
342
|
-
|
|
244
|
+
---
|
|
343
245
|
|
|
344
|
-
|
|
246
|
+
## Security Requirements
|
|
345
247
|
|
|
346
|
-
|
|
347
|
-
const { deleteAccount } = useAccountManagement({
|
|
348
|
-
onReauthRequired: async () => {
|
|
349
|
-
try {
|
|
350
|
-
// Reauthenticate with Google
|
|
351
|
-
const result = await signInWithGooglePopup();
|
|
352
|
-
return result.user ? true : false;
|
|
353
|
-
} catch (error) {
|
|
354
|
-
return false;
|
|
355
|
-
}
|
|
356
|
-
},
|
|
357
|
-
});
|
|
358
|
-
```
|
|
248
|
+
### Strategy
|
|
359
249
|
|
|
360
|
-
|
|
250
|
+
**Purpose**: Ensure account operations are secure.
|
|
361
251
|
|
|
362
|
-
|
|
252
|
+
**Rules**:
|
|
253
|
+
- MUST require recent authentication for deletion
|
|
254
|
+
- MUST validate permissions before operations
|
|
255
|
+
- MUST log security events
|
|
256
|
+
- MUST use secure token handling
|
|
257
|
+
- MUST implement proper error handling
|
|
363
258
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
259
|
+
**MUST NOT**:
|
|
260
|
+
- Allow deletion without reauthentication
|
|
261
|
+
- Skip permission checks
|
|
262
|
+
- Log sensitive data
|
|
263
|
+
- Expose tokens in errors
|
|
264
|
+
- Bypass Firebase security
|
|
265
|
+
|
|
266
|
+
### Constraints
|
|
267
|
+
|
|
268
|
+
**REAUTHENTICATION REQUIREMENTS**:
|
|
269
|
+
- Account deletion: Recent auth required
|
|
270
|
+
- Timeout: Typically 5 minutes
|
|
271
|
+
- Methods: Re-sign in with credentials
|
|
272
|
+
- Failure: Block destructive action
|
|
273
|
+
|
|
274
|
+
**SECURITY LOGGING**:
|
|
275
|
+
- Log: Account views, settings access
|
|
276
|
+
- Log: Sign out, deletion attempts
|
|
277
|
+
- Never log: Passwords, tokens, credentials
|
|
278
|
+
- Purpose: Security audit, debugging
|
|
279
|
+
|
|
280
|
+
**DATA HANDLING**:
|
|
281
|
+
- Tokens managed by Firebase SDK
|
|
282
|
+
- Secure storage for credentials
|
|
283
|
+
- No plaintext password storage
|
|
284
|
+
- Proper session cleanup
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## Navigation Integration
|
|
289
|
+
|
|
290
|
+
### Strategy
|
|
291
|
+
|
|
292
|
+
**Purpose**: Proper navigation flow for account operations.
|
|
293
|
+
|
|
294
|
+
**Rules**:
|
|
295
|
+
- MUST navigate to login after sign out
|
|
296
|
+
- MUST navigate to welcome after deletion
|
|
297
|
+
- MUST handle back navigation properly
|
|
298
|
+
- MUST maintain navigation context
|
|
299
|
+
|
|
300
|
+
**MUST NOT**:
|
|
301
|
+
- Break navigation stack
|
|
302
|
+
- Leave modals open after operations
|
|
303
|
+
- Lose user context
|
|
304
|
+
- Create navigation loops
|
|
305
|
+
|
|
306
|
+
### Constraints
|
|
307
|
+
|
|
308
|
+
**SIGN OUT FLOW**:
|
|
309
|
+
1. User confirms sign out
|
|
310
|
+
2. Clear auth state
|
|
311
|
+
3. Navigate to login screen
|
|
312
|
+
4. Replace entire navigation stack
|
|
313
|
+
5. Clear any deep links
|
|
314
|
+
|
|
315
|
+
**DELETION FLOW**:
|
|
316
|
+
1. User confirms deletion (twice)
|
|
317
|
+
2. Reauthenticate if required
|
|
318
|
+
3. Delete account
|
|
319
|
+
4. Navigate to welcome/login
|
|
320
|
+
5. Replace entire navigation stack
|
|
321
|
+
|
|
322
|
+
**STACK MANAGEMENT**:
|
|
323
|
+
- Sign out: Replace stack with login
|
|
324
|
+
- Delete account: Replace stack with welcome
|
|
325
|
+
- No back navigation to authenticated screens
|
|
326
|
+
|
|
327
|
+
---
|
|
381
328
|
|
|
382
329
|
## Related Hooks
|
|
383
330
|
|
|
384
|
-
-
|
|
385
|
-
-
|
|
386
|
-
-
|
|
331
|
+
- **`useAuth`** (`src/presentation/hooks/useAuth.ts`) - Authentication state
|
|
332
|
+
- **`useUserProfile`** (`src/presentation/hooks/useUserProfile.ts`) - Profile data
|
|
333
|
+
- **`useProfileUpdate`** (`src/presentation/hooks/useProfileUpdate.md`) - Profile editing
|
|
334
|
+
|
|
335
|
+
## Related Components
|
|
336
|
+
|
|
337
|
+
- **`AccountActions`** (`src/presentation/components/ProfileComponents.md`) - Account management UI
|