Skip to content

Commit

Permalink
Merge pull request #25 from benceszasz/dev
Browse files Browse the repository at this point in the history
Multi follow server with 7xxG
  • Loading branch information
benceszasz committed May 14, 2023
2 parents 62c5aff + 83dfe96 commit d2c3e94
Showing 1 changed file with 29 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,18 @@ public RecentData getRecentData(String patientUsername) {
if (getAuthorizationToken() != null) {
// M2M
if (this.sessionM2MEnabled)
return this.getM2MPatientData(patientUsername);
// Care Partner
if(this.sessionUser.isCarePartner())
return this.getM2MPatientData(patientUsername);
// Patient
else
// 7xxG
if(sessionMonitorData.isBle())
return this.getConnectDisplayMessage(this.sessionProfile.username, this.sessionUser.getUserRole(),
sessionCountrySettings.blePereodicDataEndpoint);
// Standalone CGM
else
return this.getLast24Hours();
// Non M2M (old logic)
else if (sessionMonitorData.isBle())
return this.getConnectDisplayMessage(this.sessionProfile.username, this.sessionUser.getUserRole(),
Expand Down Expand Up @@ -172,14 +183,8 @@ protected boolean executeLoginProcedure() {
lastErrorMessage = "";

try {
// Clear cookies
((SimpleOkHttpCookieJar) this.httpClient.cookieJar()).deleteAllCookies();

// Clear basic infos
this.sessionUser = null;
this.sessionProfile = null;
this.sessionCountrySettings = null;
this.sessionMonitorData = null;
this.clearSessionInfos();

// Open login (get SessionId and SessionData)
loginSessionResponse = this.getLoginSession();
Expand All @@ -201,10 +206,12 @@ protected boolean executeLoginProcedure() {
this.sessionProfile = this.getMyProfile();
this.sessionCountrySettings = this.getMyCountrySettings();
this.sessionM2MEnabled = this.getM2MEnabled().value;
if(!this.sessionM2MEnabled)
this.sessionMonitorData = this.getMonitorData();
//Care Partner + multi follow => patients
if(this.sessionUser.isCarePartner() && this.sessionM2MEnabled)
this.sessionPatients = this.getM2MPatients();
//Patient or Care Partner & not multi follow => monitor data
else
this.sessionMonitorData = this.getMonitorData();

} catch (Exception e) {
lastErrorMessage = e.getClass().getSimpleName() + ":" + e.getMessage();
Expand All @@ -215,22 +222,27 @@ protected boolean executeLoginProcedure() {

// Set login success if everything was ok:
if(this.sessionUser != null && this.sessionProfile != null && this.sessionCountrySettings != null && this.sessionM2MEnabled != null
&& (this.sessionM2MEnabled || this.sessionMonitorData != null))
&& ((this.sessionM2MEnabled && this.sessionUser.isCarePartner() && this.sessionPatients != null) || this.sessionMonitorData != null))
lastLoginSuccess = true;
//Clear cookies, session infos if error occured during login process
else {
((SimpleOkHttpCookieJar) this.httpClient.cookieJar()).deleteAllCookies();
this.sessionUser = null;
this.sessionProfile = null;
this.sessionCountrySettings = null;
this.sessionMonitorData = null;
this.sessionPatients = null;
this.clearSessionInfos();
}

return lastLoginSuccess;

}

protected void clearSessionInfos()
{
((SimpleOkHttpCookieJar) this.httpClient.cookieJar()).deleteAllCookies();
this.sessionUser = null;
this.sessionProfile = null;
this.sessionCountrySettings = null;
this.sessionMonitorData = null;
this.sessionPatients = null;
}

protected Response getLoginSession() throws IOException {

HttpUrl url = null;
Expand Down

0 comments on commit d2c3e94

Please sign in to comment.