Auth.gd 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. extends Node
  2. var net = NetworkedMultiplayerENet.new()
  3. var api = MultiplayerAPI.new()
  4. var port = 1909
  5. var maxplayer = 100
  6. export(NodePath) var database
  7. var cert = load('user://Certificate/x509_Certificate.crt')
  8. var key = load('user://Certificate/x509_Key.key')
  9. func _ready():
  10. print('Login listening to port: ' + str(port))
  11. net.create_server(port, maxplayer)
  12. net.set_dtls_key(key)
  13. net.set_dtls_certificate(cert)
  14. net.set_dtls_enabled(true)
  15. self.set_custom_multiplayer(api)
  16. custom_multiplayer.set_root_node(self)
  17. custom_multiplayer.set_network_peer(net)
  18. # net.connect("peer_disconnected",self,"disc")
  19. net.connect("peer_connected",self,"conn")
  20. pass # Replace with function body.
  21. func _process(_delta):
  22. custom_multiplayer.poll()
  23. var playerphsyics = preload('res://playerphysics.tscn')
  24. func conn(id):
  25. print('login client connected, id: ' + str(id))
  26. remote func RegisterPlayer(username, password, password2, email, salt, requester):
  27. var message = 'registering...'
  28. if password != password2:
  29. message = 'passwords are not equal'
  30. if username == '':
  31. message = 'put in a username'
  32. if email.find('@') == -1 or email.find('@') == 0:
  33. message = 'email is invalid'
  34. if email.find('gmail') == -1 and email.find('outlook') == -1 and email.find('yahoo') == -1:
  35. message = 'not a supported email provider'
  36. if email.find('.com') == -1:
  37. message = 'email is invalid'
  38. rpc_id(api.get_rpc_sender_id(), 'update_status', message)
  39. if message == 'registering...': return