Ejemplo n.º 1
0
        // Gets the existing user object if there is one and login the user, otherwise return error to client
        public void LoginClient(Client client, string name, string password)
        {
            if (client == null)
            {
                return;
            }

            ExtendetClient extendetClient = _clientHandler.GetExtendetClient(client);

            AuthResponse authResponse = new AuthResponse();

            if (extendetClient.Properties.Name == null)
            {
                authResponse.Success = false;
                authResponse.Error.Add("Username not found!");
            }
            else if (!_api.verifyPasswordHashBCrypt(password, extendetClient.Properties.PasswordHash))
            {
                authResponse.Success = false;
                authResponse.Error.Add("The entered password is incorrect!");
            }
            else
            {
                authResponse.Success = true;

                extendetClient.Properties.SocialClubName = client.socialClubName;
                extendetClient.Properties.HwId           = client.uniqueHardwareId;
                extendetClient.Properties.LastLogin      = DateTime.Now;

                extendetClient.Spawn();
                _clientHandler.UnRestrict(extendetClient: extendetClient);
            }

            _eventHandler.InvokeClientEvent(client, "AuthResponse",
                                            JsonConvert.SerializeObject(authResponse));
        }