@umituz/react-native-auth 3.4.31 → 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/README.md +2 -2
- package/src/presentation/components/LoginForm.md +158 -267
- package/src/presentation/components/PasswordIndicators.md +199 -410
- package/src/presentation/components/ProfileComponents.md +322 -376
- package/src/presentation/components/SocialLoginButtons.md +295 -258
- package/src/presentation/hooks/useAccountManagement.md +301 -344
- package/src/presentation/hooks/useAuth.md +271 -227
- package/src/presentation/hooks/useAuthBottomSheet.md +419 -372
- package/src/presentation/hooks/useAuthRequired.md +308 -194
- package/src/presentation/hooks/useProfileUpdate.md +251 -279
- package/src/presentation/hooks/useSocialLogin.md +307 -337
- package/src/presentation/hooks/useUserProfile.md +259 -192
|
@@ -1,380 +1,337 @@
|
|
|
1
1
|
# useAccountManagement
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Hook for account management operations (logout, delete account).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- Hesap silme (reauthentication gerektirir)
|
|
9
|
-
- Reauthentication callback desteği
|
|
10
|
-
- Loading state yönetimi
|
|
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
|
-
// Google/Apple ile yeniden authentication
|
|
21
|
-
const result = await reauthenticateWithGoogle();
|
|
22
|
-
return result.success;
|
|
23
|
-
},
|
|
24
|
-
onPasswordRequired: async () => {
|
|
25
|
-
// Şifre prompt göster
|
|
26
|
-
const password = await showPasswordPrompt();
|
|
27
|
-
return password;
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const handleLogout = async () => {
|
|
32
|
-
Alert.alert(
|
|
33
|
-
'Çıkış Yap',
|
|
34
|
-
'Çıkış yapmak istediğinizden emin misiniz?',
|
|
35
|
-
[
|
|
36
|
-
{ text: 'İptal', style: 'cancel' },
|
|
37
|
-
{
|
|
38
|
-
text: 'Çıkış',
|
|
39
|
-
onPress: logout,
|
|
40
|
-
},
|
|
41
|
-
]
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const handleDeleteAccount = async () => {
|
|
46
|
-
Alert.alert(
|
|
47
|
-
'Hesabı Sil',
|
|
48
|
-
'Bu işlem geri alınamaz. Hesabınızı silmek istediğinizden emin misiniz?',
|
|
49
|
-
[
|
|
50
|
-
{ text: 'İptal', style: 'cancel' },
|
|
51
|
-
{
|
|
52
|
-
text: 'Sil',
|
|
53
|
-
style: 'destructive',
|
|
54
|
-
onPress: deleteAccount,
|
|
55
|
-
},
|
|
56
|
-
]
|
|
57
|
-
);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<View>
|
|
62
|
-
<Button onPress={handleLogout} disabled={isLoading}>
|
|
63
|
-
Çıkış Yap
|
|
64
|
-
</Button>
|
|
65
|
-
<Button
|
|
66
|
-
onPress={handleDeleteAccount}
|
|
67
|
-
disabled={isDeletingAccount}
|
|
68
|
-
style={{ backgroundColor: 'red' }}
|
|
69
|
-
>
|
|
70
|
-
{isDeletingAccount ? 'Siliniyor...' : 'Hesabı Sil'}
|
|
71
|
-
</Button>
|
|
72
|
-
</View>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
20
|
```
|
|
76
21
|
|
|
77
|
-
|
|
22
|
+
**Hook Location**: `src/presentation/hooks/useAccountManagement.ts`
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Core Operations
|
|
27
|
+
|
|
28
|
+
### logout
|
|
29
|
+
|
|
30
|
+
**Purpose**: Sign out user and clear authentication state.
|
|
31
|
+
|
|
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
|
|
38
|
+
|
|
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
|
|
78
44
|
|
|
79
|
-
|
|
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
|
|
80
51
|
|
|
81
|
-
|
|
82
|
-
|-------|------|----------|----------|
|
|
83
|
-
| `onReauthRequired` | `() => Promise<boolean>` | No | Google/Apple ile yeniden authentication callback'i |
|
|
84
|
-
| `onPasswordRequired` | `() => Promise<string \| null>` | No | Şifre ile yeniden authentication callback'i |
|
|
52
|
+
---
|
|
85
53
|
|
|
86
|
-
###
|
|
54
|
+
### deleteAccount
|
|
87
55
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
56
|
+
**Purpose**: Permanently delete user account and all associated data.
|
|
57
|
+
|
|
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
|
|
65
|
+
|
|
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
|
|
72
|
+
|
|
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
|
|
79
|
+
|
|
80
|
+
---
|
|
94
81
|
|
|
95
82
|
## Reauthentication
|
|
96
83
|
|
|
97
|
-
|
|
84
|
+
### Strategy
|
|
98
85
|
|
|
99
|
-
|
|
86
|
+
**Purpose**: Handle Firebase requirement for recent authentication before sensitive operations.
|
|
100
87
|
|
|
101
|
-
|
|
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
|
|
102
94
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const result = await signInWithGooglePopup();
|
|
109
|
-
|
|
110
|
-
if (result.user) {
|
|
111
|
-
Alert.alert('Başarılı', 'Lütfen hesap silme işlemine devam edin');
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return false;
|
|
116
|
-
} catch (error) {
|
|
117
|
-
Alert.alert('Hata', 'Reauthentication başarısız');
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
```
|
|
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
|
|
123
100
|
|
|
124
|
-
###
|
|
101
|
+
### Constraints
|
|
125
102
|
|
|
126
|
-
|
|
103
|
+
**REAUTHENTICATION TRIGGERS**:
|
|
104
|
+
- Account deletion
|
|
105
|
+
- Password change (if implementing)
|
|
106
|
+
- Sensitive account operations
|
|
107
|
+
- Firebase-determined requirement
|
|
127
108
|
|
|
128
|
-
|
|
129
|
-
const { deleteAccount } = useAccountManagement({
|
|
130
|
-
onPasswordRequired: async () => {
|
|
131
|
-
return new Promise((resolve) => {
|
|
132
|
-
// Şifre prompt göster
|
|
133
|
-
Alert.prompt(
|
|
134
|
-
'Şifre Girin',
|
|
135
|
-
'Hesabınızı silmek için şifrenizi girin',
|
|
136
|
-
[
|
|
137
|
-
{
|
|
138
|
-
text: 'İptal',
|
|
139
|
-
onPress: () => resolve(null),
|
|
140
|
-
style: 'cancel',
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
text: 'Tamam',
|
|
144
|
-
onPress: (password) => resolve(password || null),
|
|
145
|
-
},
|
|
146
|
-
],
|
|
147
|
-
'secure-text'
|
|
148
|
-
);
|
|
149
|
-
});
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
```
|
|
109
|
+
**CALLBACK TYPES**:
|
|
153
110
|
|
|
154
|
-
|
|
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
|
|
155
116
|
|
|
156
|
-
|
|
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
|
|
157
122
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
await logout();
|
|
166
|
-
navigation.replace('Login');
|
|
167
|
-
} catch (error) {
|
|
168
|
-
Alert.alert('Hata', 'Çıkış yapılamadı');
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
const handleDeleteAccount = async () => {
|
|
173
|
-
try {
|
|
174
|
-
await deleteAccount();
|
|
175
|
-
navigation.replace('Login');
|
|
176
|
-
Alert.alert('Başarılı', 'Hesabınız silindi');
|
|
177
|
-
} catch (error) {
|
|
178
|
-
Alert.alert('Hata', 'Hesap silinemedi');
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
return (
|
|
183
|
-
<ScrollView style={styles.container}>
|
|
184
|
-
<Section title="Oturum">
|
|
185
|
-
<MenuItem
|
|
186
|
-
title="Çıkış Yap"
|
|
187
|
-
icon="log-out"
|
|
188
|
-
onPress={handleLogout}
|
|
189
|
-
/>
|
|
190
|
-
</Section>
|
|
191
|
-
|
|
192
|
-
<Section title="Tehlikeli Bölge">
|
|
193
|
-
<MenuItem
|
|
194
|
-
title="Hesabı Sil"
|
|
195
|
-
icon="trash"
|
|
196
|
-
onPress={handleDeleteAccount}
|
|
197
|
-
destructive
|
|
198
|
-
disabled={isDeletingAccount}
|
|
199
|
-
/>
|
|
200
|
-
{isDeletingAccount && <ActivityIndicator />}
|
|
201
|
-
</Section>
|
|
202
|
-
</ScrollView>
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
```
|
|
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
|
|
206
130
|
|
|
207
|
-
|
|
131
|
+
---
|
|
208
132
|
|
|
209
|
-
|
|
210
|
-
function DeleteAccountScreen() {
|
|
211
|
-
const [showReauth, setShowReauth] = useState(false);
|
|
212
|
-
const [reauthMethod, setReauthMethod] = useState<'password' | 'google' | 'apple'>('password');
|
|
213
|
-
|
|
214
|
-
const { deleteAccount, isDeletingAccount } = useAccountManagement({
|
|
215
|
-
onReauthRequired: async () => {
|
|
216
|
-
setShowReauth(true);
|
|
217
|
-
return new Promise((resolve) => {
|
|
218
|
-
// Custom reauthentication UI
|
|
219
|
-
const handleResult = (success: boolean) => {
|
|
220
|
-
setShowReauth(false);
|
|
221
|
-
resolve(success);
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
// UI'ı göster ve sonucu bekle
|
|
225
|
-
showCustomReauthUI(reauthMethod, handleResult);
|
|
226
|
-
});
|
|
227
|
-
},
|
|
228
|
-
onPasswordRequired: async () => {
|
|
229
|
-
setShowReauth(true);
|
|
230
|
-
return new Promise((resolve) => {
|
|
231
|
-
// Custom password prompt
|
|
232
|
-
showPasswordPrompt((password) => {
|
|
233
|
-
setShowReauth(false);
|
|
234
|
-
resolve(password);
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
},
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
const handleDelete = async () => {
|
|
241
|
-
try {
|
|
242
|
-
await deleteAccount();
|
|
243
|
-
Alert.alert('Başarılı', 'Hesabınız silindi');
|
|
244
|
-
} catch (error) {
|
|
245
|
-
Alert.alert('Hata', error.message);
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
return (
|
|
250
|
-
<View>
|
|
251
|
-
<Button onPress={handleDelete} disabled={isDeletingAccount}>
|
|
252
|
-
Hesabı Sil
|
|
253
|
-
</Button>
|
|
254
|
-
|
|
255
|
-
{showReauth && (
|
|
256
|
-
<ReauthenticationModal
|
|
257
|
-
method={reauthMethod}
|
|
258
|
-
onComplete={() => {
|
|
259
|
-
// Reauthentication başarılı, deleteAccount devam eder
|
|
260
|
-
}}
|
|
261
|
-
/>
|
|
262
|
-
)}
|
|
263
|
-
</View>
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
```
|
|
133
|
+
## Loading States
|
|
267
134
|
|
|
268
|
-
###
|
|
135
|
+
### Strategy
|
|
269
136
|
|
|
270
|
-
|
|
271
|
-
function DeleteAccountConfirmation() {
|
|
272
|
-
const { deleteAccount, isDeletingAccount } = useAccountManagement();
|
|
273
|
-
const [agreed, setAgreed] = useState(false);
|
|
274
|
-
|
|
275
|
-
const handleDelete = async () => {
|
|
276
|
-
if (!agreed) {
|
|
277
|
-
Alert.alert('Uyarı', 'Lütfen koşulları kabul edin');
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
Alert.alert(
|
|
282
|
-
'Hesabı Sil',
|
|
283
|
-
'Bu işlem geri alınamaz. Devam etmek istediğinizden emin misiniz?',
|
|
284
|
-
[
|
|
285
|
-
{ text: 'İptal', style: 'cancel' },
|
|
286
|
-
{
|
|
287
|
-
text: 'Sil',
|
|
288
|
-
style: 'destructive',
|
|
289
|
-
onPress: deleteAccount,
|
|
290
|
-
},
|
|
291
|
-
]
|
|
292
|
-
);
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
return (
|
|
296
|
-
<View>
|
|
297
|
-
<Text style={styles.warning}>
|
|
298
|
-
Hesabınızı silerseniz:
|
|
299
|
-
</Text>
|
|
300
|
-
<Text>• Tüm verileriniz kalıcı olarak silinir</Text>
|
|
301
|
-
<Text>• İşlemler geri alınamaz</Text>
|
|
302
|
-
<Text>• Aynı hesapla tekrar giriş yapamazsınız</Text>
|
|
303
|
-
|
|
304
|
-
<CheckBox
|
|
305
|
-
value={agreed}
|
|
306
|
-
onValueChange={setAgreed}
|
|
307
|
-
label="Hesap silme koşullarını kabul ediyorum"
|
|
308
|
-
/>
|
|
309
|
-
|
|
310
|
-
<Button
|
|
311
|
-
onPress={handleDelete}
|
|
312
|
-
disabled={!agreed || isDeletingAccount}
|
|
313
|
-
style={{ backgroundColor: 'red' }}
|
|
314
|
-
>
|
|
315
|
-
{isDeletingAccount ? 'Siliniyor...' : 'Hesabı Kalıcı Olarak Sil'}
|
|
316
|
-
</Button>
|
|
317
|
-
</View>
|
|
318
|
-
);
|
|
319
|
-
}
|
|
320
|
-
```
|
|
137
|
+
**Purpose**: Proper UX during account management operations.
|
|
321
138
|
|
|
322
|
-
|
|
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
|
|
323
144
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
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
|
+
---
|
|
204
|
+
|
|
205
|
+
## Error Handling
|
|
206
|
+
|
|
207
|
+
### Strategy
|
|
208
|
+
|
|
209
|
+
**Purpose**: Graceful handling of account operation failures.
|
|
210
|
+
|
|
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
|
|
231
|
+
|
|
232
|
+
**RECOVERY OPTIONS**:
|
|
233
|
+
- Retry operation automatically
|
|
234
|
+
- Show error with retry button
|
|
235
|
+
- Reauthenticate if required
|
|
236
|
+
- Support contact for persistent issues
|
|
237
|
+
|
|
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
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## Security Requirements
|
|
247
|
+
|
|
248
|
+
### Strategy
|
|
249
|
+
|
|
250
|
+
**Purpose**: Ensure account operations are secure.
|
|
251
|
+
|
|
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
|
|
258
|
+
|
|
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
|
+
---
|
|
368
328
|
|
|
369
|
-
##
|
|
329
|
+
## Related Hooks
|
|
370
330
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
4. **Callback'ler**: `onReauthRequired` ve `onPasswordRequired` callback'lerini sağlamazsanız, hatalar fırlatılır
|
|
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
|
|
375
334
|
|
|
376
|
-
##
|
|
335
|
+
## Related Components
|
|
377
336
|
|
|
378
|
-
-
|
|
379
|
-
- [`useSignOut`](./useAuth.md) - Çıkış yapma fonksiyonu
|
|
380
|
-
- [`useUserProfile`](./useUserProfile.md) - Profil bilgileri
|
|
337
|
+
- **`AccountActions`** (`src/presentation/components/ProfileComponents.md`) - Account management UI
|