예제 #1
0
    private void LoginRequest(int cnnId, int channelId, int recHostId, Net_LoginRequest msg)
    {
        string        randomToken = AccountUtils.GenerateRandomString(256);
        Model_Account account     = db.LoginAccount(msg.UsernameOrEmail, msg.Password, cnnId, randomToken);

        Net_LoginRequestResponse response = new Net_LoginRequestResponse();

        if (account != null)
        {
            // login was successful
            response.success       = 0;
            response.information   = "Login was successful!";
            response.connectionId  = cnnId;
            response.token         = randomToken;
            response.username      = account.Username;
            response.discriminator = account.Discriminator;
        }
        else
        {
            // login was not successful
            response.success     = 1;
            response.information = "Login attempt failed";
        }

        SendClient(recHostId, cnnId, channelId, response); // let the client know if their login attempt was successful or not
    }