Merge pull request 'feat: added user registration' (#6) from develop into production
Reviewed-on: #6pull/10/head
commit
64100fd3eb
|
@ -1,7 +1 @@
|
|||
{
|
||||
"email": "test_user@gmail.com",
|
||||
"password": "9a3d1f5ce0bbbdf38ca26740bdc5aa55",
|
||||
"token": "",
|
||||
"userType": "User",
|
||||
"name": "test_user"
|
||||
}
|
||||
{"email":"test_user@gmail.com","name":"test_user","password":"9a3d1f5ce0bbbdf38ca26740bdc5aa55","token":"cf49b818d38904019638d6b73be8ec40","userType":"User"}
|
|
@ -18,4 +18,4 @@ func _init():
|
|||
#--------------------------------------------------------------------------------------------------#
|
||||
# RPC Client
|
||||
@rpc("authority", "reliable", "call_local", 1)
|
||||
func authorizated(_token, _isAuthorized): pass
|
||||
func authorizated(): pass
|
||||
|
|
|
@ -143,3 +143,30 @@ func authorization(_login, _password):
|
|||
FileManager.add_to_log("OK | Status: 200 | Message: CLIENT AUTHORIZATED id: %s" % [client_id])
|
||||
else:
|
||||
FileManager.add_to_log("WARNING | Status: %s | Message: CLIENT NOT AUTHORIZATED id: %s - Error: %s" % [STATUS.WARNING, client_id, "Invalid login or password"])
|
||||
|
||||
|
||||
@rpc("any_peer", "reliable", "call_local", 1)
|
||||
func registration(_login, _password):
|
||||
var db = ORM.new()
|
||||
var client_id : int = multiplayer.get_remote_sender_id()
|
||||
var user = db.findOne("User", _login)
|
||||
if user:
|
||||
var reason = "User already exist"
|
||||
var rpc_response = rpc_id(client_id, 'is_registrated', false, reason)
|
||||
if rpc_response != Error.OK:
|
||||
FileManager.add_to_log("ERROR | Status: %s | Message: CLIENT NOT REGISTRATED id: %s - Error: %s" % [STATUS.ERROR, client_id, error_string(rpc_response)])
|
||||
else:
|
||||
FileManager.add_to_log("WARNING | Status: %s | Message: CLIENT NOT REGISTRATED id: %s - Error: %s" % [STATUS.WARNING, client_id, reason])
|
||||
else:
|
||||
# Add user to DB
|
||||
var rpc_response = rpc_id(client_id, 'is_registrated', true, "")
|
||||
if rpc_response != Error.OK:
|
||||
FileManager.add_to_log("ERROR | Status: %s | Message: CLIENT NOT REGISTRATED id: %s - Error: %s" % [STATUS.ERROR, client_id, error_string(rpc_response)])
|
||||
else:
|
||||
FileManager.add_to_log("OK | Status: 200 | Message: CLIENT REGISTRATED id: %s" % [client_id])
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------#
|
||||
# RPC Client
|
||||
@rpc("any_peer", "reliable", "call_local", 1)
|
||||
func is_registrated(): pass
|
||||
|
|
Loading…
Reference in New Issue