Ejemplo n.º 1
0
        //login user---------------------------------------------
        public List <string> LoginPlayer(List <string> login)
        {
            dynamic jasondata     = JObject.Parse(body);
            string  username      = jasondata.Username;
            string  password      = jasondata.Password;
            bool    alreadyOnline = false;

            for (int i = 0; i < login.Count; i++)
            {
                if (login[i] == username + "-mtcgToken")
                {
                    alreadyOnline = true;
                }
            }
            if (alreadyOnline == true)
            {
                string data   = "\nPlayer is already logged in \n";
                string status = "404 Not Found";
                string mime   = "text/plain";
                ServerResponse(status, mime, data);
                return(login);
            }

            if (Database.selectPlayerPassword(username, password) == 1)
            {
                login.Add(username + "-mtcgToken");

                string data   = "\nPlayer is logged in \n";
                string status = "200 Success";
                string mime   = "text/plain";
                ServerResponse(status, mime, data);
                return(login);
            }
            else
            {
                string data   = "\nWrong username or password \n";
                string status = "404 Not found";
                string mime   = "text/plain";
                ServerResponse(status, mime, data);
                return(login);
            }
        }