Closed KpoJIuk06 closed 2 years ago
@KpoJIuk06 Let me check with the team. I can't remember if this was going to be in an upcoming release. If not it looks like it should be not to bad to put in there.
Thanks
Chuck
@KpoJIuk06 I looked and I can see the function in out code. I did a quick test with it and it seems to be working correctly.
Test 1: I tested trying to reset the password for an account that did not exist. I saw this error in the console
{error:{code:400, errors:[{domain:global, message:EMAIL_NOT_FOUND, reason:invalid}], message:EMAIL_NOT_FOUND}} At: res://addons/godot-firebase/auth/auth.gd:384:_on_FirebaseAuth_request_completed()
Test 2: I added the email to the list of users and everything worked fine. I saw this in the console
{email:THE EMAIL WAS HERE, kind:identitytoolkit#GetOobConfirmationCodeResponse} At: res://addons/godot-firebase/auth/auth.gd:384:_on_FirebaseAuth_request_completed()
Am I missing something or are you asking for something I don't understand?
Thanks
Chuck
Done . Thanks
func _ready():
Firebase.Auth.connect("login_succeeded", self, "_on_FirebaseAuth_login_succeeded")
Firebase.Auth.connect("login_failed", self, "_on_FirebaseAuth_login_failed")
Firebase.Auth.connect("signup_succeeded", self, "_on_FirebaseAuth_signup_succeeded")
Firebase.Auth.connect("login_failed", self, "_on_FirebaseAuth_request_completed")
Firebase.Auth.connect("auth_request", self, "_on_FirebaseAuth_auth_request")
func _on_FirebaseAuth_auth_request(result_code, result_content): print("result_auth_code: " + str(result_code)) print("result_auth_content: " + str(result_content)) if result_code != 1: $Notification.text = "Wrong email address" else: $Notification.text = "We just sent an email with a password reset link, please click the link to reset your password"
You shouldn't need to do some of that. The plugin has some builtin code to display errors in the console for things.
This is inside the auth.gd
file
func _on_FirebaseAuth_request_completed(result : int, response_code : int, headers : PoolStringArray, body : PoolByteArray) -> void:
print_debug(JSON.parse(body.get_string_from_utf8()).result)
is_busy = false
var res
if response_code == 0:
# Mocked error results to trigger the correct signal.
# Can occur if there is no internet connection, or the service is down,
# in which case there is no json_body (and thus parsing would fail).
res = {"error": {
"code": "Connection error",
"message": "Error connecting to auth service"}}
else:
var bod = body.get_string_from_utf8()
var json_result = JSON.parse(bod)
if json_result.error != OK:
Firebase._printerr("Error while parsing auth body json")
emit_signal("auth_request", ERR_PARSE_ERROR, "Error while parsing auth body json")
return
res = json_result.result
you can probably parse out this message
its enough for me with result code =) @BearDooks
Thanks for letting us know it is working now
First I would like to thank you for the work you have done. During the use of functions and signals, a password recovery signal was required. To understand that if the letter is sent, issue a message about sending the letter, and if the wrong email is entered, then issue an error message. Since the signals shown below, as well as in the documentation, none of them returned a response.
func _ready(): Firebase.Auth.connect("login_succeeded", self, "_on_FirebaseAuth_login_succeeded") Firebase.Auth.connect("login_failed", self, "_on_FirebaseAuth_login_failed")
Firebase.Auth.connect("signup_succeeded", self, "_on_FirebaseAuth_signup_succeeded") pass
func _on_FirebaseAuth_login_failed(error_code, message): print("error code: " + str(error_code)) print("message: " + str(message))
func _on_FirebaseAuth_signup_succeeded(email): print("Sent a Reset password email!") Firebase.Auth.save_auth(email)
func _on_Reset_button_up(): var email = $mail.text Firebase.Auth.send_password_reset_email(email) pass # Replace with function body.