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

Fix #379: Replaced "JavaScript" feature tag. #380

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Changes from all commits
Commits
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
18 changes: 9 additions & 9 deletions addons/godot-firebase/auth/auth.gd
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ var _local_provider : AuthProvider = AuthProvider.new()
func _ready() -> void:
tcp_timer.wait_time = tcp_timeout
tcp_timer.timeout.connect(_tcp_stream_timer)

Utilities.fix_http_request(self)
if OS.get_name() == "HTML5" or OS.get_name() == "Web":
_local_uri += "tmp_js_export.html"
Expand Down Expand Up @@ -281,7 +281,7 @@ func get_auth_with_redirect(provider: AuthProvider) -> void:
url_endpoint+=key+"="+provider.params[key]+"&"
url_endpoint += provider.params.redirect_type+"="+_local_uri
url_endpoint = _clean_url(url_endpoint)
if OS.get_name() == "HTML5" and OS.has_feature("JavaScript"):
if OS.get_name() == "HTML5" and OS.has_feature("web"):
JavaScriptBridge.eval('window.location.replace("' + url_endpoint + '")')
elif Engine.has_singleton(_INAPP_PLUGIN) and OS.get_name() == "iOS":
#in app for ios if the iOS plugin exists
Expand Down Expand Up @@ -334,7 +334,7 @@ func exchange_token(code : String, redirect_uri : String, request_url: String, _
if err != OK:
is_busy = false
Firebase._printerr("Error exchanging tokens: %s" % err)

# Open a web page in browser redirecting to Google oAuth2 page for the current project
# Once given user's authorization, a token will be generated.
# NOTE** with this method, the authorization process will be copy-pasted
Expand All @@ -357,13 +357,13 @@ func _tcp_stream_timer() -> void:
if _local_provider.params.response_type in splitted[0]:
token = splitted[1]
break

if token == "":
login_failed.emit()
peer.disconnect_from_host()
tcp_server.stop()
return

var data : PackedByteArray = '<p style="text-align:center">&#128293; You can close this window now. &#128293;</p>'.to_ascii_buffer()
peer.put_data(("HTTP/1.1 200 OK\n").to_ascii_buffer())
peer.put_data(("Server: Godot Firebase SDK\n").to_ascii_buffer())
Expand All @@ -375,7 +375,7 @@ func _tcp_stream_timer() -> void:
await self.login_succeeded
peer.disconnect_from_host()
tcp_server.stop()


# Function used to logout of the system, this will also remove_at the local encrypted auth file if there is one
func logout() -> void:
Expand Down Expand Up @@ -419,7 +419,7 @@ func _on_FirebaseAuth_request_completed(result : int, response_code : int, heade
Firebase._printerr("Error while parsing auth body json")
auth_request.emit(ERR_PARSE_ERROR, "Error while parsing auth body json")
return

res = json

if response_code == HTTPClient.RESPONSE_OK:
Expand Down Expand Up @@ -619,8 +619,8 @@ func begin_refresh_countdown() -> void:

func get_token_from_url(provider: AuthProvider):
var token_type: String = provider.params.response_type if provider.params.response_type == "code" else "access_token"
if OS.has_feature('JavaScript'):
var token = JavaScriptBridge.eval("""
if OS.has_feature('web'):
var token = JavaScriptBridge.eval("""
var url_string = window.location.href.replaceAll('?#', '?');
var url = new URL(url_string);
url.searchParams.get('"""+token_type+"""');
Expand Down