Auth.gd 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. extends Node
  2. var net = NetworkedMultiplayerENet.new()
  3. var api = MultiplayerAPI.new()
  4. var port = 1909
  5. var maxplayer = 100
  6. #var cert = load('user://Certificate/x509_Certificate.crt')
  7. #var key = load('user://Certificate/x509_Key.key')
  8. func _ready():
  9. print('Login listening to port: ' + str(port))
  10. net.create_server(port, maxplayer)
  11. # net.set_dtls_key(key)
  12. # net.set_dtls_certificate(cert)
  13. # net.set_dtls_enabled(true)
  14. self.set_custom_multiplayer(api)
  15. custom_multiplayer.set_root_node(self)
  16. custom_multiplayer.set_network_peer(net)
  17. # net.connect("peer_disconnected",self,"disc")
  18. net.connect("peer_connected",self,"conn")
  19. pass # Replace with function body.
  20. func _process(_delta):
  21. custom_multiplayer.poll()
  22. var playerphsyics = preload('res://playerphysics.tscn')
  23. func conn(id):
  24. print('login client connected, id: ' + str(id))
  25. export(NodePath) var PostgreSQL
  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.length() < 3:
  31. # message = 'username must be at least three letters'
  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. print(message)
  39. rpc_id(api.get_rpc_sender_id(), 'update_status', message)
  40. # if message == 'registering...': return
  41. for i in 1024: password = (password+salt).sha256_text()
  42. print('adding new data to the login db...')
  43. get_node(PostgreSQL).Create('login_db',['email','username','password','salt','creation_date'],email, username, password, salt, OS.get_unix_time())