@@ -210,12 +210,6 @@ class _ClerkUserProfileState extends State<ClerkUserProfile>
210
210
child: _ExternalAccountList (
211
211
user: user,
212
212
env: auth.env,
213
- onAddNew: () => ClerkPage .show (
214
- context,
215
- builder: (context) => ConnectAccountPanel (
216
- onDone: (context) => Navigator .of (context).pop (),
217
- ),
218
- ),
219
213
),
220
214
),
221
215
],
@@ -234,12 +228,36 @@ class _ExternalAccountList extends StatelessWidget {
234
228
const _ExternalAccountList ({
235
229
required this .user,
236
230
required this .env,
237
- required this .onAddNew,
238
231
});
239
232
240
233
final clerk.User user;
241
234
final clerk.Environment env;
242
- final VoidCallback onAddNew;
235
+
236
+ void _onAddNew (BuildContext context) {
237
+ ClerkPage .show (
238
+ context,
239
+ builder: (context) => ConnectAccountPanel (
240
+ onDone: (context) async {
241
+ Navigator .of (context).pop ();
242
+
243
+ final auth = ClerkAuth .of (context);
244
+ if (auth.user? .externalAccounts case final accounts? ) {
245
+ for (final account in accounts) {
246
+ if (account.verification.errorMessage case String errorMessage) {
247
+ auth.addError (
248
+ clerk.AuthError (
249
+ message: errorMessage,
250
+ code: clerk.AuthErrorCode .serverErrorResponse,
251
+ ),
252
+ );
253
+ await auth.deleteExternalAccount (account: account);
254
+ }
255
+ }
256
+ }
257
+ },
258
+ ),
259
+ );
260
+ }
243
261
244
262
@override
245
263
Widget build (BuildContext context) {
@@ -281,7 +299,7 @@ class _ExternalAccountList extends StatelessWidget {
281
299
),
282
300
GestureDetector (
283
301
behavior: HitTestBehavior .opaque,
284
- onTap: onAddNew ,
302
+ onTap: () => _onAddNew (context) ,
285
303
child: Row (
286
304
mainAxisAlignment: MainAxisAlignment .start,
287
305
children: [
@@ -320,27 +338,26 @@ class _IdentifierList extends StatelessWidget {
320
338
crossAxisAlignment: CrossAxisAlignment .stretch,
321
339
children: [
322
340
if (identifiers case List <clerk.UserIdentifyingData > identifiers) //
323
- for (final ident in identifiers) //
341
+ for (final uid in identifiers) //
324
342
Padding (
325
343
padding: bottomPadding16,
326
344
child: Row (
327
345
crossAxisAlignment: CrossAxisAlignment .start,
328
346
children: [
329
347
Expanded (
330
348
child: Text (
331
- format? .call (ident .identifier) ?? ident .identifier,
349
+ format? .call (uid .identifier) ?? uid .identifier,
332
350
maxLines: 1 ,
333
351
overflow: TextOverflow .ellipsis,
334
352
),
335
353
),
336
- if (ident .isUnverified) //
354
+ if (uid .isUnverified) //
337
355
_RowLabel (
338
356
label: localizations.unverified,
339
357
color: ClerkColors .incarnadine,
340
- onTap: () =>
341
- onIdentifierUnverified.call (ident.identifier),
358
+ onTap: () => onIdentifierUnverified.call (uid.identifier),
342
359
),
343
- if (user.isPrimary (ident )) //
360
+ if (user.isPrimary (uid )) //
344
361
_RowLabel (label: localizations.primary),
345
362
],
346
363
),
0 commit comments