Skip to content
This repository was archived by the owner on Nov 19, 2025. It is now read-only.

Commit 940b2d0

Browse files
committed
account deletion
1 parent 09ca222 commit 940b2d0

9 files changed

Lines changed: 617 additions & 178 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SkySync - File Management Application
22

3-
![Skysync logo](assets/Logo-name.png)
3+
![Skysync logo](assets/Logo1.png)
44

55
## Overview
66

assets/Logo1.png

35 KB
Loading

assets/lang/en.json

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
"forgot.enter_token_title": "Enter reset token",
172172
"forgot.reset_title": "Reset password",
173173
"forgot.enter_token_desc": "Enter the reset token that was sent to your email address.",
174-
"forgot.enter_email_desc": "Enter your email address and we'll send you a reset token.",
174+
"forgot.enter_email_desc": "Enter your password address and we'll send you a reset token.",
175175
"forgot.email_label": "Email address",
176176
"forgot.send_token": "Send reset token",
177177
"forgot.token_sent": "Reset token sent to: {email}",
@@ -564,5 +564,31 @@
564564
"forgot.remember_password": "Remember your password?",
565565
"delete.title": "Delete account",
566566
"delete.password": "Enter password",
567-
"delete.send_token": "Send code"
567+
"delete.email": "Emter email",
568+
"delete.enter_email": "Enter your email address",
569+
"delete.instructions_sent": "Password reset instructions have been sent to your email address.",
570+
"delete.error_occurred": "An error occurred. Please try again later.",
571+
"delete.too_many_attempts": "Too many reset attempts. Please try again later.",
572+
"delete.enter_token": "Enter reset token",
573+
"delete.invalid_or_expired_token": "Invalid or expired token. Please request a new one.",
574+
"delete.invalid_token": "Invalid token. Please try again.",
575+
"delete.enter_token_title": "Enter reset token",
576+
"delete.reset_title": "Delete account",
577+
"delete.enter_token_desc": "Enter the reset token that was sent to your email address.",
578+
"delete.enter_email_desc": "Enter your password and we'll send you a reset token.",
579+
"delete.email_label": "Email address",
580+
"delete.send_token": "Send delete token",
581+
"delete.token_sent": "Delete token sent to: {email}",
582+
"delete.token_label": "Reset token",
583+
"delete.new_password": "New password",
584+
"delete.confirm_new_password": "Confirm new password",
585+
"delete.reset_button": "Delete account",
586+
"delete.password_reset_success": "Password has been successfully reset! You can now login.",
587+
"delete.password_reset_error": "An error occurred while resetting password. Please try again.",
588+
"delete.token_hint": "Reset token",
589+
"delete.back_to_email": "Back to email input",
590+
"delete.back_to_login": "Back to login",
591+
"delete.remember_password": "Remember your password?",
592+
"delete.account_deleted_successfully": "Your account has been permanently deleted successfully!",
593+
"delete.delete_account_button": "Delete Account"
568594
}

assets/lang/pl.json

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,5 +560,32 @@
560560
"forgot.remember_password": "Pamiętasz hasło? ",
561561
"delete.title": "Usuń konto",
562562
"delete.password": "Wprowadź hasło",
563-
"delete.send_token": "Wyślij kod"
563+
"delete.send_token": "Wyślij kod",
564+
"delete.email": "Wprowadź email",
565+
"delete.enter_email": "Wprowadź swój adres email",
566+
"delete.instructions_sent": "Instrukcje usuwania konta zostały wysłane na Twój adres email.",
567+
"delete.error_occurred": "Wystąpił błąd. Spróbuj ponownie później.",
568+
"delete.too_many_attempts": "Zbyt wiele prób usunięcia. Spróbuj ponownie później.",
569+
"delete.enter_token": "Wprowadź token usuwania",
570+
"delete.invalid_or_expired_token": "Nieprawidłowy lub wygasły token. Poproś o nowy.",
571+
"delete.invalid_token": "Nieprawidłowy token. Spróbuj ponownie.",
572+
"delete.enter_token_title": "Wprowadź token usuwania",
573+
"delete.reset_title": "Usuń konto",
574+
"delete.enter_token_desc": "Wprowadź token usuwania, który został wysłany na Twój email.",
575+
"delete.enter_email_desc": "Wprowadź swój email, a wyślemy Ci token usuwania.",
576+
"delete.email_label": "Adres email",
577+
"delete.send_token": "Wyślij token usuwania",
578+
"delete.token_sent": "Token usuwania wysłany na: {email}",
579+
"delete.token_label": "Token usuwania",
580+
"delete.new_password": "Nowe hasło",
581+
"delete.confirm_new_password": "Potwierdź nowe hasło",
582+
"delete.reset_button": "Usuń konto",
583+
"delete.password_reset_success": "Hasło zostało pomyślnie zresetowane! Możesz się teraz zalogować.",
584+
"delete.password_reset_error": "Wystąpił błąd podczas resetowania hasła. Spróbuj ponownie.",
585+
"delete.token_hint": "Token usuwania",
586+
"delete.back_to_email": "Powrót do wprowadzania email",
587+
"delete.back_to_login": "Powrót do logowania",
588+
"delete.remember_password": "Pamiętasz hasło?",
589+
"delete.account_deleted_successfully": "Twoje konto zostało pomyślnie usunięte na zawsze!",
590+
"delete.delete_account_button": "Usuń konto"
564591
}

lib/pages/delete_account_page.dart

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ class DeleteAccountPage extends StatefulWidget {
88
const DeleteAccountPage({super.key});
99

1010
@override
11-
State<DeleteAccountPage> createState() => _ForgotPasswordPageState();
11+
State<DeleteAccountPage> createState() => _DeletePasswordPageState();
1212
}
1313

14-
class _ForgotPasswordPageState extends State<DeleteAccountPage> {
14+
class _DeletePasswordPageState extends State<DeleteAccountPage> {
1515
final TextEditingController _emailController = TextEditingController();
1616
final TextEditingController _passwordController = TextEditingController();
1717
final TextEditingController _tokenController = TextEditingController();
@@ -27,10 +27,10 @@ class _ForgotPasswordPageState extends State<DeleteAccountPage> {
2727
super.dispose();
2828
}
2929

30-
Future<void> _handleResetPassword() async {
30+
Future<void> _handleDeletePassword() async {
3131
if (_emailController.text.isEmpty) {
3232
ScaffoldMessenger.of(context).showSnackBar(
33-
SnackBar(content: Text('forgot.enter_email'.tr())),
33+
SnackBar(content: Text('delete.enter_email'.tr())),
3434
);
3535
return;
3636
}
@@ -40,14 +40,14 @@ class _ForgotPasswordPageState extends State<DeleteAccountPage> {
4040
});
4141

4242
try {
43-
final response = await ApiService.resetPassword(email: _emailController.text);
43+
final response = await ApiService.deleteAccount(email: _emailController.text);
4444

4545
if (!mounted) return;
4646

4747
if (response.statusCode == 200) {
4848
ScaffoldMessenger.of(context).showSnackBar(
4949
SnackBar(
50-
content: Text('forgot.instructions_sent'.tr()),
50+
content: Text('delete.instructions_sent'.tr()),
5151
backgroundColor: Colors.green,
5252
),
5353
);
@@ -59,10 +59,10 @@ class _ForgotPasswordPageState extends State<DeleteAccountPage> {
5959
});
6060
} else {
6161
final data = jsonDecode(response.body);
62-
String errorMessage = 'forgot.error_occurred'.tr();
62+
String errorMessage = 'delete.error_occurred'.tr();
6363

6464
if (response.statusCode == 429) {
65-
errorMessage = 'forgot.too_many_attempts'.tr();
65+
errorMessage = 'delete.too_many_attempts'.tr();
6666
} else if (data['detail']) {
6767
errorMessage = data['detail'];
6868
}
@@ -82,7 +82,7 @@ class _ForgotPasswordPageState extends State<DeleteAccountPage> {
8282
if (!mounted) return;
8383
ScaffoldMessenger.of(context).showSnackBar(
8484
SnackBar(
85-
content: Text('forgot.error_occurred'.tr()),
85+
content: Text('delete.error_occurred'.tr()),
8686
backgroundColor: Colors.red,
8787
),
8888
);
@@ -96,7 +96,7 @@ class _ForgotPasswordPageState extends State<DeleteAccountPage> {
9696
Future<void> _handleTokenSubmit() async {
9797
if (_tokenController.text.isEmpty) {
9898
ScaffoldMessenger.of(context).showSnackBar(
99-
SnackBar(content: Text('forgot.enter_token'.tr())),
99+
SnackBar(content: Text('delete.enter_token'.tr())),
100100
);
101101
return;
102102
}
@@ -106,26 +106,32 @@ class _ForgotPasswordPageState extends State<DeleteAccountPage> {
106106
});
107107

108108
try {
109-
final response = await ApiService.validateResetToken(token: _tokenController.text);
109+
final response = await ApiService.confirmDelete(token: _tokenController.text);
110110

111111
if (!mounted) return;
112112

113113
if (response.statusCode == 200) {
114114
final data = jsonDecode(response.body);
115-
if (data['valid'] == true) {
116-
Navigator.pushNamed(context, '/reset-password', arguments: _tokenController.text);
117-
} else {
118-
ScaffoldMessenger.of(context).showSnackBar(
119-
SnackBar(
120-
content: Text('forgot.invalid_or_expired_token'.tr()),
121-
backgroundColor: Colors.red,
122-
),
123-
);
124-
}
115+
ScaffoldMessenger.of(context).showSnackBar(
116+
SnackBar(
117+
content: Text('delete.account_deleted_successfully'.tr()),
118+
backgroundColor: Colors.green,
119+
),
120+
);
121+
122+
// Navigate back to login page after successful account deletion
123+
Navigator.pushNamedAndRemoveUntil(context, '/login', (route) => false);
125124
} else {
125+
final data = jsonDecode(response.body);
126+
String errorMessage = 'delete.error_occurred'.tr();
127+
128+
if (data['detail']) {
129+
errorMessage = data['detail'];
130+
}
131+
126132
ScaffoldMessenger.of(context).showSnackBar(
127133
SnackBar(
128-
content: Text('forgot.invalid_token'.tr()),
134+
content: Text(errorMessage),
129135
backgroundColor: Colors.red,
130136
),
131137
);
@@ -134,7 +140,7 @@ class _ForgotPasswordPageState extends State<DeleteAccountPage> {
134140
if (!mounted) return;
135141
ScaffoldMessenger.of(context).showSnackBar(
136142
SnackBar(
137-
content: Text('forgot.error_occurred'.tr()),
143+
content: Text('delete.error_occurred'.tr()),
138144
backgroundColor: Colors.red,
139145
),
140146
);
@@ -190,7 +196,7 @@ class _ForgotPasswordPageState extends State<DeleteAccountPage> {
190196
mainAxisAlignment: MainAxisAlignment.center,
191197
children: [
192198
Text(
193-
_showTokenInput ? 'forgot.enter_token_title'.tr() : 'forgot.reset_title'.tr(),
199+
_showTokenInput ? 'delete.enter_token_title'.tr() : 'delete.reset_title'.tr(),
194200
style: const TextStyle(
195201
fontSize: 28,
196202
fontWeight: FontWeight.bold,
@@ -200,8 +206,8 @@ class _ForgotPasswordPageState extends State<DeleteAccountPage> {
200206
const SizedBox(height: 16),
201207
Text(
202208
_showTokenInput
203-
? 'forgot.enter_token_desc'.tr()
204-
: 'forgot.enter_email_desc'.tr(),
209+
? 'delete.enter_token_desc'.tr()
210+
: 'delete.enter_email_desc'.tr(),
205211
textAlign: TextAlign.center,
206212
style: TextStyle(
207213
fontSize: 16,
@@ -216,8 +222,8 @@ class _ForgotPasswordPageState extends State<DeleteAccountPage> {
216222
child: SizedBox(
217223
width: width,
218224
child: UsernameField(
219-
controller: _passwordController,
220-
labelText: 'delete.password'.tr(),
225+
controller: _emailController,
226+
labelText: 'delete.email'.tr(),
221227
),
222228
),
223229
),
@@ -228,7 +234,7 @@ class _ForgotPasswordPageState extends State<DeleteAccountPage> {
228234
width: width,
229235
child: AnimatedButton(
230236
text: 'delete.send_token'.tr(),
231-
onPressed: _handleResetPassword,
237+
onPressed: _handleDeletePassword,
232238
isLoading: _isLoading,
233239
),
234240
),
@@ -243,15 +249,15 @@ class _ForgotPasswordPageState extends State<DeleteAccountPage> {
243249
decoration: BoxDecoration(
244250
color: Colors.green.shade50,
245251
borderRadius: BorderRadius.circular(8),
246-
border: Border.all(color: Colors.green.shade200),
252+
border: Border.all(color: Color(0xFF764ba2)),
247253
),
248254
child: Row(
249255
children: [
250-
Icon(Icons.check_circle, color: Colors.green.shade600, size: 20),
256+
Icon(Icons.check_circle, color: Color(0xFF764ba2), size: 20),
251257
const SizedBox(width: 8),
252258
Expanded(
253259
child: Text(
254-
'forgot.token_sent'.tr(namedArgs: {'email': _sentToEmail}),
260+
'delete.token_sent'.tr(namedArgs: {'email': _sentToEmail}),
255261
style: TextStyle(
256262
color: const Color(0xFF764ba2),
257263
fontWeight: FontWeight.w500,
@@ -269,8 +275,8 @@ class _ForgotPasswordPageState extends State<DeleteAccountPage> {
269275
child: TextField(
270276
controller: _tokenController,
271277
decoration: InputDecoration(
272-
labelText: 'forgot.token_label'.tr(),
273-
hintText: 'forgot.token_hint'.tr(),
278+
labelText: 'delete.token_label'.tr(),
279+
hintText: 'delete.token_hint'.tr(),
274280
border: OutlineInputBorder(
275281
borderRadius: BorderRadius.circular(12),
276282
),
@@ -284,7 +290,7 @@ class _ForgotPasswordPageState extends State<DeleteAccountPage> {
284290
child: SizedBox(
285291
width: width,
286292
child: AnimatedButton(
287-
text: 'forgot.reset_button'.tr(),
293+
text: 'delete.delete_account_button'.tr(),
288294
onPressed: _handleTokenSubmit,
289295
isLoading: _isLoading,
290296
),
@@ -302,7 +308,7 @@ class _ForgotPasswordPageState extends State<DeleteAccountPage> {
302308
});
303309
},
304310
child: Text(
305-
'forgot.back_to_email'.tr(),
311+
'delete.back_to_email'.tr(),
306312
style: TextStyle(
307313
color: Colors.white,
308314
fontWeight: FontWeight.bold,
@@ -314,19 +320,12 @@ class _ForgotPasswordPageState extends State<DeleteAccountPage> {
314320
Row(
315321
mainAxisAlignment: MainAxisAlignment.center,
316322
children: [
317-
Text(
318-
'forgot.remember_password'.tr(),
319-
style: TextStyle(
320-
fontSize: 16,
321-
color: Colors.white.withValues(alpha: 0.9),
322-
),
323-
),
324323
InkWell(
325324
onTap: () {
326325
Navigator.pop(context);
327326
},
328327
child: Text(
329-
'forgot.back_to_login'.tr(),
328+
'delete.back_to_login'.tr(),
330329
style: const TextStyle(
331330
fontSize: 16,
332331
color: Colors.white,

0 commit comments

Comments
 (0)