Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

signupNewUser implementation #33

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f63e1b3
signupNewUser implementation
JacobCube Sep 10, 2024
0972225
email property partially implemented - not all EPs return it
JacobCube Sep 13, 2024
6580738
Merge branch 'master' into signup_new_user
JacobCube Sep 16, 2024
1ac38d7
"File must end with a newline (\n)" fix
JacobCube Sep 30, 2024
34f4848
Merge branch 'signup_new_user' of https://github.com/JacobCube/fireba…
JacobCube Sep 30, 2024
6e663f0
ktlintFormat
nbransby Oct 5, 2024
ab943b6
remove * imports
nbransby Oct 5, 2024
d496798
correct mock Firebase project implementation
JacobCube Oct 21, 2024
bffad78
Merge branch 'signup_new_user' of https://github.com/JacobCube/fireba…
JacobCube Oct 21, 2024
e8a723e
updateEmail and verifyBeforeUpdateEmail implementation
JacobCube Oct 21, 2024
e51997d
added todo
JacobCube Oct 21, 2024
aa0c563
Merge branch 'master' into signup_new_user
JacobCube Oct 30, 2024
25efe1c
ktlint formatting + update of user data after signInWithCustomToken +…
JacobCube Nov 7, 2024
040414c
refactor
JacobCube Nov 7, 2024
5102655
Merge branch 'master' into signup_new_user
JacobCube Nov 29, 2024
607dad8
Update README.md
nbransby Sep 16, 2024
bce0cd2
correct mock Firebase project implementation
JacobCube Oct 21, 2024
ec07676
ktlintFormat
nbransby Oct 5, 2024
4d2a745
remove * imports
nbransby Oct 5, 2024
76f990a
updateEmail and verifyBeforeUpdateEmail implementation
JacobCube Oct 21, 2024
694da88
added todo
JacobCube Oct 21, 2024
3dea253
Test Auth against emulator
fmasa Oct 7, 2024
c811e39
ktlint formatting + update of user data after signInWithCustomToken +…
JacobCube Nov 7, 2024
9465f7a
refactor
JacobCube Nov 7, 2024
372e307
Update gradle.properties
nbransby Nov 28, 2024
740c5b4
Update README.md
nbransby Nov 28, 2024
6ee896e
Master merge
JacobCube Jan 22, 2025
9984757
Merge remote-tracking branch 'origin/signup_new_user' into signup_new…
JacobCube Jan 22, 2025
b5e3d0d
Merge branch 'master' into signup_new_user
JacobCube Jan 22, 2025
7447442
Ktlint fixes
JacobCube Jan 22, 2025
d94afed
Merge remote-tracking branch 'origin/signup_new_user' into signup_new…
JacobCube Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion src/main/java/com/google/firebase/auth/FirebaseAuth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,38 @@ class FirebaseAuth constructor(val app: FirebaseApp) : InternalAuthProvider {
return source.task
}

fun createUserWithEmailAndPassword(email: String, password: String): Task<AuthResult> {
val source = TaskCompletionSource<AuthResult>()
val body = RequestBody.create(
json,
JsonObject(mapOf("email" to JsonPrimitive(email), "password" to JsonPrimitive(password), "returnSecureToken" to JsonPrimitive(true))).toString()
)
val request = Request.Builder()
.url("https://www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key=" + app.options.apiKey)
.post(body)
.build()
client.newCall(request).enqueue(object : Callback {

override fun onFailure(call: Call, e: IOException) {
source.setException(FirebaseException(e.toString(), e))
}

@Throws(IOException::class)
override fun onResponse(call: Call, response: Response) {
if (!response.isSuccessful) {
source.setException(
createAuthInvalidUserException("signupNewUser", request, response)
)
} else {
val responseBody = response.body()?.use { it.string() } ?: ""
val user = FirebaseUserImpl(app, jsonParser.parseToJsonElement(responseBody).jsonObject)
refreshToken(user, source) { AuthResult { it } }
}
}
})
return source.task
}

fun signInWithEmailAndPassword(email: String, password: String): Task<AuthResult> {
val source = TaskCompletionSource<AuthResult>()
val body = RequestBody.create(
Expand Down Expand Up @@ -425,7 +457,6 @@ class FirebaseAuth constructor(val app: FirebaseApp) : InternalAuthProvider {
}

fun sendPasswordResetEmail(email: String, settings: ActionCodeSettings?): Task<Unit> = TODO()
fun createUserWithEmailAndPassword(email: String, password: String): Task<AuthResult> = TODO()
fun signInWithCredential(authCredential: AuthCredential): Task<AuthResult> = TODO()
fun checkActionCode(code: String): Task<ActionCodeResult> = TODO()
fun confirmPasswordReset(code: String, newPassword: String): Task<Unit> = TODO()
Expand Down
Loading