Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit 5e2f0db

Browse files
committed
corrected user cancel flow code to show message on connect ui
1 parent d3267d5 commit 5e2f0db

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

app/src/main/java/com/microsoft/graph/connect/AuthenticationManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ public void onError(MsalException exception) {
160160
public void onCancel() {
161161
/* User canceled the authentication */
162162
Log.d(TAG, "User cancelled login.");
163+
if (mActivityCallback != null)
164+
mActivityCallback.onCancel();
163165
}
164166
};
165167
}

app/src/main/java/com/microsoft/graph/connect/ConnectActivity.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ public void onClick(View v) {
7575
}
7676

7777
private void connect() {
78-
try {
7978

8079
// The sample app is having the PII enable setting on the MainActivity. Ideally, app should decide to enable Pii or not,
8180
// if it's enabled, it should be the setting when the application is onCreate.
@@ -119,16 +118,13 @@ private void connect() {
119118
Log.d(TAG, "User at this position does not exist: " + e.toString());
120119
showConnectErrorUI(e.getMessage());
121120

122-
}
123-
124-
} catch (IllegalStateException e) {
125-
Log.d(TAG, "MSAL Exception Generated: " + e.toString());
126-
showConnectErrorUI(e.getMessage());
121+
}catch (IllegalStateException e) {
122+
Log.d(TAG, "MSAL Exception Generated: " + e.toString());
123+
showConnectErrorUI(e.getMessage());
127124

128125
} catch (Exception e) {
129126
showConnectErrorUI();
130127
}
131-
132128
}
133129

134130
/**
@@ -277,9 +273,16 @@ public void onError(MsalException exception) {
277273

278274
}
279275

276+
@Override
277+
public void onError(Exception exception) {
278+
showMessage(exception.getMessage());
279+
showConnectErrorUI(exception.getMessage());
280+
}
281+
280282
@Override
281283
public void onCancel() {
282284
showMessage("User cancelled the flow.");
285+
showConnectErrorUI("User cancelled the flow.");
283286

284287
}
285288

app/src/main/java/com/microsoft/graph/connect/MSALAuthenticationCallback.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
interface MSALAuthenticationCallback {
1111
void onSuccess(AuthenticationResult authenticationResult);
1212
void onError(MsalException exception);
13+
void onError(Exception exception);
1314
void onCancel();
1415
}

0 commit comments

Comments
 (0)