From df5b81d5ba4c3cf0ddffac806a314e322bf35051 Mon Sep 17 00:00:00 2001 From: akhil-deriv Date: Wed, 3 Jul 2024 20:21:07 +0400 Subject: [PATCH] implemented new multi token authorization change --- .../features/auth/cubit/deriv_auth_cubit.dart | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart b/packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart index 049b221f9..aa1f5599e 100644 --- a/packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart +++ b/packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart @@ -107,15 +107,17 @@ class DerivAuthCubit extends Cubit final List accountList = await authService.getLatestAccounts(); accountTokens = accountList - .where((AccountModel account) => - account.token != null && token != account.token) + .where((AccountModel account) => account.token != null) .map((AccountModel account) => account.token!) .toList(); } else { accountTokens = tokenList; } + if (!accountTokens.contains(token)) { + accountTokens.add(token); + } await _tokenLoginRequest( - token, + 'MULTI', tokenList: accountTokens, accounts: await authService.getLatestAccounts(), ); @@ -202,14 +204,16 @@ class DerivAuthCubit extends Cubit return; } else { tokenList = accountList - .where((AccountModel account) => - account.token != null && defaultAccountToken != account.token) + .where((AccountModel account) => account.token != null) .map((AccountModel account) => account.token!) .toList(); - } + if (!tokenList.contains(defaultAccountToken)) { + tokenList.add(defaultAccountToken); + } + } await _tokenLoginRequest( - defaultAccountToken, + 'MULTI', accounts: accountList, tokenList: tokenList, );