Login part I

This commit is contained in:
Stanislas Dolcini 2018-10-02 18:56:02 +02:00
parent d606a805b8
commit fc9912fddd
2 changed files with 38 additions and 5 deletions

View file

@ -7,8 +7,31 @@ func _on_login_button_pressed():
func _on_play_button_pressed(): func _on_play_button_pressed():
emit_signal( "login_button_pressed" ) #emit_signal( "login_button_pressed" )
var username = get_node("h_box_container/v_box_container/margin_container/login_box/email_box/email_edit").get_text();
if username != null and username != "":
do_request(username)
func _on_quit_button_pressed(): func _on_quit_button_pressed():
self.get_tree().quit() self.get_tree().quit()
func do_request(username):
var headers = ["Content-Type: application/json"]
#$HTTPRequest.request("http://lirria.khaganat.net/login/r2_login.php?cmd=ask&login=" + username)
$HTTPRequest.request("http://lirria.khaganat.net/login/r2_login.php?cmd=ask", headers, true, HTTPClient.METHOD_GET, "&login=" + username)
func _on_HTTPRequest_request_completed(result, response_code, headers, body):
var s = body.get_string_from_utf8().split(":")
var ctn = s[1]
print(ctn)
func _make_post_request(url, data_to_send, use_ssl):
# Convert data to json string:
var query = JSON.print(data_to_send)
# Add 'Content-Type' header:
var headers = ["Content-Type: application/json"]
$HTTPRequest.request(url, headers, use_ssl, HTTPClient.METHOD_POST, query)

View file

@ -60,7 +60,15 @@ theme = ExtResource( 1 )
script = ExtResource( 2 ) script = ExtResource( 2 )
_sections_unfolded = [ "Material", "Theme", "Visibility", "custom_styles" ] _sections_unfolded = [ "Material", "Theme", "Visibility", "custom_styles" ]
[node name="background" type="TextureRect" parent="." index="0"] [node name="HTTPRequest" type="HTTPRequest" parent="." index="0"]
download_file = ""
use_threads = false
body_size_limit = -1
max_redirects = 8
_sections_unfolded = [ "Pause" ]
[node name="background" type="TextureRect" parent="." index="1"]
anchor_left = 0.0 anchor_left = 0.0
anchor_top = 0.0 anchor_top = 0.0
@ -77,7 +85,7 @@ expand = true
stretch_mode = 7 stretch_mode = 7
_sections_unfolded = [ "Visibility" ] _sections_unfolded = [ "Visibility" ]
[node name="OLD_buttons_background" type="TextureRect" parent="." index="1"] [node name="OLD_buttons_background" type="TextureRect" parent="." index="2"]
anchor_left = 1.0 anchor_left = 1.0
anchor_top = 0.0 anchor_top = 0.0
@ -95,7 +103,7 @@ texture = ExtResource( 4 )
stretch_mode = 0 stretch_mode = 0
_sections_unfolded = [ "Size Flags" ] _sections_unfolded = [ "Size Flags" ]
[node name="center_container" type="CenterContainer" parent="." index="2"] [node name="center_container" type="CenterContainer" parent="." index="3"]
editor/display_folded = true editor/display_folded = true
visible = false visible = false
@ -378,7 +386,7 @@ percent_visible = 1.0
lines_skipped = 0 lines_skipped = 0
max_lines_visible = -1 max_lines_visible = -1
[node name="h_box_container" type="HBoxContainer" parent="." index="3"] [node name="h_box_container" type="HBoxContainer" parent="." index="4"]
anchor_left = 0.0 anchor_left = 0.0
anchor_top = 0.0 anchor_top = 0.0
@ -890,6 +898,8 @@ flat = false
align = 1 align = 1
_sections_unfolded = [ "Margin", "Material", "Rect", "Size Flags", "Theme", "Visibility", "custom_colors", "custom_constants", "custom_fonts" ] _sections_unfolded = [ "Margin", "Material", "Rect", "Size Flags", "Theme", "Visibility", "custom_colors", "custom_constants", "custom_fonts" ]
[connection signal="request_completed" from="HTTPRequest" to="." method="_on_HTTPRequest_request_completed"]
[connection signal="pressed" from="center_container/v_box_container/login_button" to="." method="_on_login_button_pressed"] [connection signal="pressed" from="center_container/v_box_container/login_button" to="." method="_on_login_button_pressed"]
[connection signal="pressed" from="center_container/v_box_container/quit_button" to="center_container/v_box_container/quit_button" method="_on_quit_button_pressed"] [connection signal="pressed" from="center_container/v_box_container/quit_button" to="center_container/v_box_container/quit_button" method="_on_quit_button_pressed"]