Skip to content

Commit

Permalink
waqas/fix_forced_logout_if_no_token_found_for_a_logidId
Browse files Browse the repository at this point in the history
  • Loading branch information
waqas-younas-deriv committed Jul 4, 2024
1 parent 1c6277d commit ae7663a
Showing 1 changed file with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,23 @@ class DerivAuthService extends BaseAuthService {
responseAuthorizeEntity!.copyWith(
signupProvider: signupProvider,
refreshToken: refreshToken,
accountList: responseAuthorizeEntity.accountList
?.map(
(AccountListItem accountListItem) => accountListItem.copyWith(
token: accounts
.where(
(AccountModel element) =>
element.accountId == accountListItem.loginid,
)
.firstOrNull
?.token ??
token,
),
)
.toList(),
accountList: responseAuthorizeEntity.accountList?.map(
(AccountListItem accountListItem) {
final AccountModel? account = accounts.firstWhereOrNull(
(AccountModel element) =>
element.accountId == accountListItem.loginid,
);

if (account?.token == null) {
throw DerivAuthException(
message: 'Login is Expired',
type: AuthErrorType.expiredAccount,
);
}

return accountListItem.copyWith(token: account!.token);
},
).toList(),
);

await authRepository.onLogin(_enhancedAuthorizeEntity);
Expand Down

0 comments on commit ae7663a

Please sign in to comment.