Skip to content

Commit 18a9076

Browse files
@W-20005462: [Android] Toggle for clearCookies after login
1 parent bc71b88 commit 18a9076

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

libs/SalesforceSDK/src/com/salesforce/androidsdk/app/SalesforceSDKManager.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ import kotlinx.coroutines.Dispatchers.Main
149149
import kotlinx.coroutines.launch
150150
import kotlinx.coroutines.withTimeoutOrNull
151151
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
152-
import org.jetbrains.annotations.Debug
153152
import java.lang.String.CASE_INSENSITIVE_ORDER
154153
import java.net.URI
155154
import java.util.Locale.US
@@ -336,6 +335,15 @@ open class SalesforceSDKManager protected constructor(
336335
*/
337336
var additionalOauthKeys: List<String>? = null
338337

338+
/**
339+
* Determines if the authentication web view's cookies will be cleared after
340+
* authentication. The default behavior is true to protect against re-use
341+
* of authentication related cookies and duplication authentication action.
342+
* Only apps the specifically require persistent cookies should set this to
343+
* false.
344+
*/
345+
var clearCookiesAfterLogin = true
346+
339347
/**
340348
* The login brand. In the following example, "<brand>" should be set here.
341349
* https://community.force.com/services/oauth2/authorize/<brand>?response_type=code&...

libs/SalesforceSDK/src/com/salesforce/androidsdk/ui/LoginViewModel.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,10 @@ open class LoginViewModel(val bootConfig: BootConfig) : ViewModel() {
318318
onAuthFlowError: (error: String, errorDesc: String?, e: Throwable?) -> Unit,
319319
onAuthFlowSuccess: (userAccount: UserAccount) -> Unit,
320320
) {
321-
// Clear cookies when we finish auth to prevent automatic re-login
322-
// if the user tries to add another user right away.
323-
clearCookies()
321+
// Clear cookies after successful authentication to prevent automatic re-login if the user tries to add another user right away.
322+
if (SalesforceSDKManager.getInstance().clearCookiesAfterLogin) {
323+
clearCookies()
324+
}
324325
authCodeForJwtFlow = null
325326
onAuthFlowComplete(
326327
tokenResponse = tr,

0 commit comments

Comments
 (0)