Skip to content

Commit 8b5c2cf

Browse files
Merge pull request #437 from syntaxerror247/fix_oAuth_login_succeeded_emitting_twice
fix_oAuth_login_succeeded_emitting_twice
2 parents 0712236 + 138ddd8 commit 8b5c2cf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

addons/godot-firebase/auth/auth.gd

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ var auth : Dictionary = {}
4848
var _needs_refresh : bool = false
4949
var is_busy : bool = false
5050
var has_child : bool = false
51+
var is_oauth_login: bool = false
5152

5253

5354
var tcp_server : TCPServer = TCPServer.new()
@@ -290,16 +291,15 @@ func get_auth_with_redirect(provider: AuthProvider) -> void:
290291
else:
291292
set_local_provider(provider)
292293
OS.shell_open(url_endpoint)
293-
print(url_endpoint)
294294

295295

296296
# Login with Google oAuth2.
297297
# A token is automatically obtained using an authorization code using @get_google_auth()
298298
# @provider_id and @request_uri can be changed
299299
func login_with_oauth(_token: String, provider: AuthProvider) -> void:
300300
if _token:
301+
is_oauth_login = true
301302
var token : String = _token.uri_decode()
302-
print(token)
303303
var is_successful: bool = true
304304
if provider.should_exchange:
305305
exchange_token(token, _local_uri, provider.access_token_uri, provider.get_client_id(), provider.get_client_secret())
@@ -426,7 +426,6 @@ func _on_FirebaseAuth_request_completed(result : int, response_code : int, heade
426426
return
427427

428428
res = json
429-
430429
if response_code == HTTPClient.RESPONSE_OK:
431430
if not res.has("kind"):
432431
auth = get_clean_keys(res)
@@ -439,7 +438,7 @@ func _on_FirebaseAuth_request_completed(result : int, response_code : int, heade
439438

440439
if _needs_refresh:
441440
_needs_refresh = false
442-
login_succeeded.emit(auth)
441+
if not is_oauth_login: login_succeeded.emit(auth)
443442
else:
444443
match res.kind:
445444
RESPONSE_SIGNUP:
@@ -466,6 +465,7 @@ func _on_FirebaseAuth_request_completed(result : int, response_code : int, heade
466465
auth_request.emit(res.error.code, res.error.message)
467466
requesting = Requests.NONE
468467
auth_request_type = Auth_Type.NONE
468+
is_oauth_login = false
469469

470470

471471

0 commit comments

Comments
 (0)