Skip to content

Commit b1d69e7

Browse files
committed
wip: Email provider integration
1 parent 42ebf15 commit b1d69e7

File tree

3 files changed

+706
-854
lines changed

3 files changed

+706
-854
lines changed

auth/src/main/java/com/firebase/ui/auth/compose/AuthState.kt

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.firebase.ui.auth.compose
1616

17+
import com.firebase.ui.auth.compose.configuration.auth_provider.AuthProvider
1718
import com.google.firebase.auth.AuthCredential
1819
import com.google.firebase.auth.AuthResult
1920
import com.google.firebase.auth.FirebaseUser
@@ -205,6 +206,44 @@ abstract class AuthState private constructor() {
205206
"AuthState.RequiresProfileCompletion(user=$user, missingFields=$missingFields)"
206207
}
207208

209+
/**
210+
* The user needs to sign in with a different provider.
211+
*
212+
* Emitted when a user tries to sign up with an email that already exists
213+
* and needs to use the existing provider to sign in instead.
214+
*
215+
* @property provider The [AuthProvider] the user should sign in with
216+
* @property email The email address of the existing account
217+
*/
218+
class RequiresSignIn(
219+
val provider: AuthProvider,
220+
val email: String
221+
) : AuthState() {
222+
override fun equals(other: Any?): Boolean {
223+
if (this === other) return true
224+
if (other !is RequiresSignIn) return false
225+
return provider == other.provider &&
226+
email == other.email
227+
}
228+
229+
override fun hashCode(): Int {
230+
var result = provider.hashCode()
231+
result = 31 * result + email.hashCode()
232+
return result
233+
}
234+
235+
override fun toString(): String =
236+
"AuthState.RequiresSignIn(provider=$provider, email=$email)"
237+
}
238+
239+
/**
240+
* Pending credential for an anonymous upgrade merge conflict.
241+
*
242+
* Emitted when an anonymous user attempts to convert to a permanent account but
243+
* Firebase detects that the target email already belongs to another user. The UI can
244+
* prompt the user to resolve the conflict by signing in with the existing account and
245+
* later linking the stored [pendingCredential].
246+
*/
208247
class MergeConflict(
209248
val pendingCredential: AuthCredential
210249
) : AuthState() {
@@ -239,4 +278,4 @@ abstract class AuthState private constructor() {
239278
@JvmStatic
240279
val Cancelled: Cancelled = Cancelled()
241280
}
242-
}
281+
}

0 commit comments

Comments
 (0)