Skip to content

Commit ec02d07

Browse files
committed
fix: cache result in onRestoreInstanceState for process death recovery, add @volatile to delegateCallback, make login startInternal private
1 parent ad0df64 commit ec02d07

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

auth0/src/main/java/com/auth0/android/provider/LifecycleAwareCallback.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import com.auth0.android.callback.Callback
1919
* @param onDetached called when a result arrives but the callback is already detached
2020
*/
2121
internal class LifecycleAwareCallback<S>(
22-
private var delegateCallback: Callback<S, AuthenticationException>?,
22+
@Volatile private var delegateCallback: Callback<S, AuthenticationException>?,
2323
lifecycleOwner: LifecycleOwner,
2424
private val onDetached: (success: S?, error: AuthenticationException?) -> Unit,
2525
) : Callback<S, AuthenticationException>, DefaultLifecycleObserver {

auth0/src/main/java/com/auth0/android/provider/WebAuthProvider.kt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,22 @@ public object WebAuthProvider {
204204
state,
205205
object : Callback<Credentials, AuthenticationException> {
206206
override fun onSuccess(result: Credentials) {
207-
for (callback in callbacks) {
208-
callback.onSuccess(result)
207+
if (callbacks.isNotEmpty()) {
208+
for (callback in callbacks) {
209+
callback.onSuccess(result)
210+
}
211+
} else {
212+
pendingLoginResult.set(PendingResult.Success(result))
209213
}
210214
}
211215

212216
override fun onFailure(error: AuthenticationException) {
213-
for (callback in callbacks) {
214-
callback.onFailure(error)
217+
if (callbacks.isNotEmpty()) {
218+
for (callback in callbacks) {
219+
callback.onFailure(error)
220+
}
221+
} else {
222+
pendingLoginResult.set(PendingResult.Failure(error))
215223
}
216224
}
217225
},
@@ -713,7 +721,7 @@ public object WebAuthProvider {
713721
startInternal(context, effectiveCallback)
714722
}
715723

716-
internal fun startInternal(
724+
private fun startInternal(
717725
context: Context,
718726
callback: Callback<Credentials, AuthenticationException>
719727
) {

0 commit comments

Comments
 (0)