Skip to content

Commit 74ac6e8

Browse files
Merge pull request #428 from T0d3v/4.x
Add link_account() function
2 parents 8b5c2cf + ecd204a commit 74ac6e8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

addons/godot-firebase/auth/auth.gd

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ var _update_profile_body : Dictionary = {
140140
"returnSecureToken":true
141141
}
142142

143+
var link_account_body : Dictionary = {
144+
"idToken":"",
145+
"email":"",
146+
"password":"",
147+
"returnSecureToken":true
148+
}
149+
143150
var _local_port : int = 8060
144151
var _local_uri : String = "http://localhost:%s/"%_local_port
145152
var _local_provider : AuthProvider = AuthProvider.new()
@@ -555,6 +562,18 @@ func update_account(idToken : String, displayName : String, photoUrl : String, d
555562
is_busy = false
556563
Firebase._printerr("Error updating account: %s" % err)
557564

565+
# Link account with Email and Password
566+
func link_account(email : String, password : String) -> void:
567+
if _is_ready():
568+
is_busy = true
569+
link_account_body.idToken = auth.idtoken
570+
link_account_body.email = email
571+
link_account_body.password = password
572+
var err = request(_base_url + _update_account_request_url, _headers, HTTPClient.METHOD_POST, JSON.stringify(link_account_body))
573+
if err != OK:
574+
is_busy = false
575+
Firebase._printerr("Error updating account: %s" % err)
576+
558577

559578
# Function to send a account verification email
560579
func send_account_verification_email() -> void:

0 commit comments

Comments
 (0)