Source:
<code>private UserSession getSessionFromAccount(Study study, CriteriaContext context, Account account) { StudyParticipant participant = participantService.getParticipant(study, account, false); if (participant.getLanguages().isEmpty() && !context.getLanguages().isEmpty()) { participant = new StudyParticipant.Builder().copyOf(participant) .withLanguages(context.getLanguages()).build(); account.setLanguages(context.getLanguages()); <START> accountDao.updateAccount(account, false); <END> } UserSession session = new UserSession(participant); UserSession existingSession = cacheProvider.getUserSessionByUserId(account.getId()); if (existingSession != null) { session.setSessionToken(existingSession.getSessionToken()); session.setInternalSessionToken(existingSession.getInternalSessionToken()); } else { session.setSessionToken(BridgeUtils.generateGuid()); session.setInternalSessionToken(BridgeUtils.generateGuid()); } session.setAuthenticated(true); session.setEnvironment(config.getEnvironment()); session.setStudyIdentifier(study.getStudyIdentifier()); session.setReauthToken(account.getReauthToken()); CriteriaContext newContext = new CriteriaContext.Builder() .withContext(context) .withHealthCode(session.getHealthCode()) .withUserId(session.getId()) .withLanguages(session.getParticipant().getLanguages()) .withUserDataGroups(session.getParticipant().getDataGroups()) .build(); session.setConsentStatuses(consentService.getConsentStatuses(newContext, account)); return session; }</code><technical_language>This fail, for example, if reauth is enabled update reauth token, if a channel signIn verifies channel. accountDao.editAccount()</technical_language>

Target:
private UserSession getSessionFromAccount(Study study, CriteriaContext context, Account account) { StudyParticipant participant = participantService.getParticipant(study, account, false); if (participant.getLanguages().isEmpty() && !context.getLanguages().isEmpty()) { participant = new StudyParticipant.Builder().copyOf(participant) .withLanguages(context.getLanguages()).build(); accountDao.editAccount(study.getStudyIdentifier(), participant.getHealthCode(), accountToEdit -> accountToEdit.setLanguages(context.getLanguages())); } UserSession session = new UserSession(participant); UserSession existingSession = cacheProvider.getUserSessionByUserId(account.getId()); if (existingSession != null) { session.setSessionToken(existingSession.getSessionToken()); session.setInternalSessionToken(existingSession.getInternalSessionToken()); } else { session.setSessionToken(BridgeUtils.generateGuid()); session.setInternalSessionToken(BridgeUtils.generateGuid()); } session.setAuthenticated(true); session.setEnvironment(config.getEnvironment()); session.setStudyIdentifier(study.getStudyIdentifier()); session.setReauthToken(account.getReauthToken()); CriteriaContext newContext = new CriteriaContext.Builder() .withContext(context) .withHealthCode(session.getHealthCode()) .withUserId(session.getId()) .withLanguages(session.getParticipant().getLanguages()) .withUserDataGroups(session.getParticipant().getDataGroups()) .build(); session.setConsentStatuses(consentService.getConsentStatuses(newContext, account)); return session; }