@@ -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