Skip to content

Commit

Permalink
implemented new multi token authorization change
Browse files Browse the repository at this point in the history
  • Loading branch information
akhil-deriv committed Jul 3, 2024
1 parent 4503c81 commit df5b81d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/deriv_auth/lib/features/auth/cubit/deriv_auth_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,17 @@ class DerivAuthCubit extends Cubit<DerivAuthState>
final List<AccountModel> 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(),
);
Expand Down Expand Up @@ -202,14 +204,16 @@ class DerivAuthCubit extends Cubit<DerivAuthState>
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,
);
Expand Down

0 comments on commit df5b81d

Please sign in to comment.