Browse Source

added server side verifications

galo 1 năm trước cách đây
mục cha
commit
21df7199d4
4 tập tin đã thay đổi với 25 bổ sung18 xóa
  1. 14 2
      Auth.gd
  2. 3 11
      Login.gd
  3. 5 2
      loginnetcode.gd
  4. 3 3
      main.tscn

+ 14 - 2
Auth.gd

@@ -30,5 +30,17 @@ var playerphsyics = preload('res://playerphysics.tscn')
 func conn(id):
 	print('login client connected, id: ' + str(id))
 
-remote func RegisterPlayer(username, password, email, salt, requester):
-	print(username + " is registering")
+remote func RegisterPlayer(username, password, password2, email, salt, requester):
+	var message = 'registering...'
+	if password != password2:
+		message = 'passwords are not equal'
+	if username == '':
+		message = 'put in a username'
+	if email.find('@') == -1 or email.find('@') == 0:
+		message = 'email is invalid'
+	if email.find('gmail') == -1 and email.find('outlook') == -1 and email.find('yahoo') == -1:
+		message = 'not a supported email provider'
+	if email.find('.com') == -1:
+		message = 'email is invalid'
+	rpc_id(api.get_rpc_sender_id(), 'update_status', message)
+	if message == 'registering...': return

+ 3 - 11
Login.gd

@@ -51,16 +51,8 @@ func _on_Register2_button_down():
 	var email = $register/VBoxContainer/HBoxContainer4/LineEdit2.get_text()
 	var salt = str(OS.get_system_time_msecs())
 	$register/VBoxContainer/Label.text = ''
-	if password != password2:
-		$register/VBoxContainer/Label.text = 'passwords are not equal'
-		return
-	if username == '':
-		$register/VBoxContainer/Label.text = 'put in a username'
-		return
-	if not password.length() > 5:
-		$register/VBoxContainer/Label.text = 'password is too short'
-		return
-	for i in 1024: password = (password+salt).sha256_text()
-	get_parent().get_node("Loginetcode").Register(username, password, email, salt)
+	for i in 512: password = (password+salt).sha256_text()
+	for i in 512: password2 = (password2+salt).sha256_text()
+	get_parent().get_node("Loginetcode").Register(username, password, password2, email, salt)
 	password = null
 

+ 5 - 2
loginnetcode.gd

@@ -28,5 +28,8 @@ func _On_Connection_Failed():
 func _On_Connection_Succeeded():
 	print("Connected to game server")
 
-func Register(username, password, email, salt):
-	rpc_id(1,"RegisterPlayer", username, password, email, salt, api.get_rpc_sender_id())
+func Register(username, password, password2, email, salt):
+	rpc_id(1,"RegisterPlayer", username, password, password2, email, salt, api.get_rpc_sender_id())
+
+remote func update_status(message):
+	get_parent().get_node('LoginUI/register/VBoxContainer/Label').text = message

+ 3 - 3
main.tscn

@@ -48,6 +48,7 @@ render_target_v_flip = true
 [node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin1"]
 modulate = Color( 0, 0.811765, 1, 1 )
 frames = SubResource( 5 )
+frame = 1
 playing = true
 offset = Vector2( 32, 32 )
 
@@ -59,7 +60,6 @@ render_target_v_flip = true
 
 [node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin2"]
 frames = SubResource( 5 )
-frame = 3
 speed_scale = 0.8
 playing = true
 offset = Vector2( 32, 32 )
@@ -73,7 +73,7 @@ render_target_v_flip = true
 [node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin3"]
 modulate = Color( 1, 0, 0, 1 )
 frames = SubResource( 5 )
-frame = 1
+frame = 2
 speed_scale = 1.2
 playing = true
 offset = Vector2( 32, 32 )
@@ -87,7 +87,7 @@ render_target_v_flip = true
 [node name="Goblin" type="AnimatedSprite" parent="Textures/Goblin4"]
 modulate = Color( 1, 0, 0.984314, 1 )
 frames = SubResource( 5 )
-frame = 1
+frame = 2
 speed_scale = 0.9
 playing = true
 offset = Vector2( 32, 32 )