Exemplo n.º 1
0
    public void SendCreateAccount(string username, string password, string email)
    {
        if (!Utility.IsUsername(username))
        {
            // Invalid Username
            LobbyScene.Instance.ChangeAuthenticationMessage("Username is Invalid");
            LobbyScene.Instance.EnableInputs();
            return;
        }

        if (!Utility.IsEmail(email))
        {
            // Invalid email
            LobbyScene.Instance.ChangeAuthenticationMessage("Email is Invalid");
            LobbyScene.Instance.EnableInputs();
            return;
        }

        if (password == null || password == "")
        {
            // Invalid Password
            LobbyScene.Instance.ChangeAuthenticationMessage("Password is empty");
            LobbyScene.Instance.EnableInputs();
            return;
        }

        Net_CreateAccount ca = new Net_CreateAccount();

        ca.Username = username;
        ca.Password = Utility.Sha256FromString(password);
        ca.Email    = email;

        LobbyScene.Instance.ChangeAuthenticationMessage("Sending Request");
        SendServer(ca);
    }
Exemplo n.º 2
0
    private void CreateAccount(int cnnId, int channelId, int recHostId, Net_CreateAccount ca)
    {
        Net_CreateAccountResponse resp = new Net_CreateAccountResponse();

        resp.success = db.CreateAccount(ca.Username, ca.Password, ca.Email);
        SendClient(recHostId, cnnId, channelId, resp);
    }
Exemplo n.º 3
0
    public void SendCreateAccount(string username, string password, string email)
    {
        if (!Utility.IsUsername(username))
        {
            // Invalid username
            LobbyScene.Instance.ChangeAuthenticationMessage("Username is invalid!");
            LobbyScene.Instance.EnableInputs();
            return;
        }

        if (!Utility.IsUsername(username))
        {
            // Invalid username
            LobbyScene.Instance.ChangeAuthenticationMessage("Email is invalid!");
            LobbyScene.Instance.EnableInputs();
            return;
        }

        if (string.IsNullOrEmpty(password))
        {
            // Invalid username
            LobbyScene.Instance.ChangeAuthenticationMessage("Password is empty!");
            LobbyScene.Instance.EnableInputs();
            return;
        }

        Net_CreateAccount msg = new Net_CreateAccount();

        msg.Username = username;
        msg.Password = Utility.Sha256FromString(password);
        msg.Email    = email;

        LobbyScene.Instance.ChangeAuthenticationMessage("Sending request ...");
        SendServer(msg);
    }
Exemplo n.º 4
0
    public void SendCreateAccount(string username, string password, string email)
    {
        Net_CreateAccount ca = new Net_CreateAccount();

        ca.Username = username;
        ca.Password = password;
        ca.Email    = email;
        SendServer(ca);
    }
Exemplo n.º 5
0
    public void TEST()
    {
        Net_CreateAccount ca = new Net_CreateAccount();

        ca.Username = "******";
        ca.Password = "******";
        ca.Email    = "*****@*****.**";

        SendServer(ca);
    }
Exemplo n.º 6
0
    public void SendCreateAccount(string username, string password, string email)
    {
        Net_CreateAccount ca = new Net_CreateAccount();

        ca.Username = username;
        ca.Password = Utility.Sha256FromString(password);
        ca.Email    = email;

        SendServer(ca);
    }
Exemplo n.º 7
0
    private void CreateAccount(int connectionId, int channelId, int recHostId, Net_CreateAccount ca)
    {
        Debug.Log(string.Format("{0}, {1}, {2}", ca.Username, ca.Password, ca.Email));

        Net_OnCreateAccount oca = new Net_OnCreateAccount();

        oca.Success     = 1;
        oca.Information = "Account was created!";

        SendClient(recHostId, connectionId, oca);
    }
Exemplo n.º 8
0
 private void CreateAccount(int connectionID, int recHostID, Net_CreateAccount ca)
 {
     if (mdb.CreateAccount(ca.username, ca.password, ca.email))
     {
         //respond to client (success)
         SendClient(connectionID, recHostID, new Net_OnCreateAccount(1));
         //deal with client data
         Debug.Log(string.Format("[Login Server]: Created Account: {0}: ({1})", ca.username, ca.email));
     }
     else
     {
         //respond to client (invalid)
         SendClient(connectionID, recHostID, new Net_OnCreateAccount(0));
     }
 }
Exemplo n.º 9
0
    private void CreateAccount(int connectionId, int channelId, int receiveHostId, Net_CreateAccount createAccount)
    {
        Net_OnCreateAcoount onCreateAccount = new Net_OnCreateAcoount();

        //insertAccount return bool for check succes
        if (dataBase.InsertAccount(createAccount.Username, createAccount.Password, createAccount.Email))
        {
            onCreateAccount.Succes      = 1;
            onCreateAccount.Information = "Account was created!";
        }
        else
        {
            onCreateAccount.Succes      = 0;
            onCreateAccount.Information = "Error on creating account";
        }
        SendClient(receiveHostId, connectionId, onCreateAccount);
    }
Exemplo n.º 10
0
    private void CreateAccount(int connectionId, int channelId, int recievingHostId, Net_CreateAccount msg)
    {
        Net_OnCreateAccount rmsg = new Net_OnCreateAccount();

        if (db.InsertAccount(msg.Username, msg.Password, msg.Email))
        {
            rmsg.Success     = 1;
            rmsg.Information = "Account was created!";
        }
        else
        {
            rmsg.Success     = 0;
            rmsg.Information = "There was an error creating the account!";
        }

        SendClient(recievingHostId, connectionId, rmsg);
    }
Exemplo n.º 11
0
    private void CreateAccount(int cnnId, int channelId, int recHostId, Net_CreateAccount ca)
    {
        // Debug.Log(string.Format("{0},{1},{2}",ca.Username,ca.Password,ca.Email));

        Net_OnCreateAccount oca = new Net_OnCreateAccount();

        if (db.InsertAccount(ca.Username, ca.Password, ca.Email))
        {
            oca.Success     = 1;
            oca.Information = "Account was Created";
        }
        else
        {
            oca.Success     = 0;
            oca.Information = "There was an error creating account!";
        }


        SendClient(recHostId, cnnId, oca);
    }
Exemplo n.º 12
0
    public void SendCreateAccount(string username, string playerType)
    {
        Net_CreateAccount ca = new Net_CreateAccount(username, playerType);

        SendServer(ca, reliableChannel);
    }
Exemplo n.º 13
0
    void CreateAccount(int cnnId, int channelId, int recHostId, Net_CreateAccount ca)
    {
        Net_OnCreateAccount oca = new Net_OnCreateAccount(cnnId, ca.userName, ca.playerType);

        SendClient(cnnId, oca);
    }
Exemplo n.º 14
0
    public void submitCreateAccount()
    {
        string username  = createUsernameField.text;
        string password1 = createPasswordField.text;
        string password2 = createPasswordConfirmationField.text;
        string email     = createEmailField.text;

        // password validation
        if (password1 != password2)
        {
            Debug.Log("Password mismatch");
            if (createAccountInfoText != null)
            {
                createAccountInfoText.text = "Passwords do not match";
            }
            return;
        }
        if (password1.Length < 8)
        {
            Debug.Log("Password must be at least 8 characters");
            createAccountInfoText.text = "Password must be at least 8 characters";
            return;
        }
        if (password1.Length > 64)
        {
            Debug.Log("Maximum password length is 64 characters");
            createAccountInfoText.text = "Maximum password length is 64 characters";

            return;
        }

        // username validation
        if (username.Length < 4)
        {
            Debug.Log("Username must be at least 4 characters");
            createAccountInfoText.text = "Username must be at least 4 characters";

            return;
        }
        if (username.Length > 16)
        {
            Debug.Log("Username must be 16 characters or less");
            createAccountInfoText.text = "Username must be 16 characters or less";

            return;
        }
        if (!AccountUtils.IsUsername(username))
        {
            Debug.Log("Username contains invalid characters. Only use a-z (capital or lowercase) and 0-9");
            createAccountInfoText.text = "Username contains invalid characters. Only use a-z (capital or lowercase) and 0-9";

            return;
        }

        // email validation
        if (!AccountUtils.IsEmail(email))
        {
            Debug.Log(email + " is not an email");
            createAccountInfoText.text = email + " is not an email";

            return;
        }

        // all validation is done so can send server a message and lock the UI
        if (Client.Instance.getIsStarted()) // make sure we're connected to the internet first
        {
            lockUi();
            Net_CreateAccount netMsg = new Net_CreateAccount();
            netMsg.Email    = email;
            netMsg.Password = password1;
            netMsg.Username = username;
            Client.Instance.SendServer(netMsg);
        }
        else
        {
            throw new Exception("Client is not connected to server");
        }
    }