public byte[] Handle(string path, Stream requestData,
                RequestFactory.IOSHttpRequest httpRequest, WifiConsoleHandler.IOSHttpResponse httpResponse)
        {
            httpResponse.ContentType = "text/html";

            Request request = RequestFactory.CreateRequest(string.Empty, httpRequest);
            AuroraWeb.Environment env = new AuroraWeb.Environment(request);

            string result = m_WebApp.Services.ForgotPasswordGetRequest(env);

            return WebAppUtils.StringToBytes(result);
        }
        public byte[] Handle(string path, Stream requestData,
                RequestFactory.IOSHttpRequest httpRequest, WifiConsoleHandler.IOSHttpResponse httpResponse)
        {
            StreamReader sr = new StreamReader(requestData);
            string body = sr.ReadToEnd();
            sr.Close();
            body = body.Trim();

            httpResponse.ContentType = "text/html";

            string resource = GetParam(path);
            try
            {
                string[] pars = SplitParams(path);
                if (pars.Length == 1) // /wifi/recover/token?email=email
                {
                    string token = pars[0];
                    if (httpRequest.Query.ContainsKey("email") && httpRequest.Query["email"] != null)
                    {
                        string email = HttpUtility.UrlDecode(httpRequest.Query["email"].ToString());
                        Request req = RequestFactory.CreateRequest(string.Empty, httpRequest);
                        AuroraWeb.Environment env = new AuroraWeb.Environment(req);

                        string result = m_WebApp.Services.RecoverPasswordGetRequest(env, email, token);

                        return WebAppUtils.StringToBytes(result);
                    }
                    else
                        m_Log.DebugFormat("[PASSWORD RECOVER GET HANDLER]: Query part does not contain email variable");
                }
                else
                    m_Log.DebugFormat("[PASSWORD RECOVER GET HANDLER]: Path does not have 1 params, it has {0}", pars.Length);
            }
            catch (Exception e)
            {
                m_Log.DebugFormat("[PASSWORD RECOVER GET HANDLER]: Exception {0}", e);
            }

            return WebAppUtils.FailureResult();
        }
        public byte[] Handle(string path, Stream requestData,
                RequestFactory.IOSHttpRequest httpRequest, WifiConsoleHandler.IOSHttpResponse httpResponse)
        {
            StreamReader sr = new StreamReader(requestData);
            string body = sr.ReadToEnd();
            sr.Close();
            body = body.Trim();

            httpResponse.ContentType = "text/html";

            string resource = GetParam(path);
            try
            {
                Dictionary<string, object> request =
                        WebUtils.ParseQueryString(body);

                string token = String.Empty;
                if (request.ContainsKey("token"))
                    token = request["token"].ToString();
                string email = String.Empty;
                if (request.ContainsKey("email"))
                    email = request["email"].ToString();

                string newPassword = String.Empty;
                if (request.ContainsKey("newpassword"))
                    newPassword = request["newpassword"].ToString();

                Request req = RequestFactory.CreateRequest(string.Empty, httpRequest);
                AuroraWeb.Environment env = new AuroraWeb.Environment(req);

                string result = m_WebApp.Services.RecoverPasswordPostRequest(env, email, token, newPassword);
                return WebAppUtils.StringToBytes(result);
            }
            catch (Exception e)
            {
                m_Log.DebugFormat("[FORGOT PASSWORD POST HANDLER]: Exception {0}", e);
            }

            return WebAppUtils.FailureResult();
        }
Ejemplo n.º 4
0
        public byte[] Handle(string path, Stream requestData,
                RequestFactory.IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            string result = string.Empty;
            try
            {
                Request request = RequestFactory.CreateRequest(string.Empty, httpRequest);
                AuroraWeb.Environment env = new AuroraWeb.Environment(request);

                string resource = GetParam(path);
                //m_log.DebugFormat("[XXX]: resource {0}", resource);
                if (resource.StartsWith("/data/simulators"))
                {
                    result = m_WebApp.Services.ConsoleSimulatorsRequest(env);
                    httpResponse.ContentType = "application/xml";
                }
                else if (resource.StartsWith("/heartbeat"))
                {
                    result = m_WebApp.Services.ConsoleHeartbeat(env);
                    httpResponse.ContentType = "application/xml";
                }
                else
                {
                    result = m_WebApp.Services.ConsoleRequest(env);
                    httpResponse.ContentType = "text/html";
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[CONSOLE HANDLER]: Exception {0}: {1}", e.Message, e.StackTrace);
            }

            return WebAppUtils.StringToBytes(result);
        }