Example #1
0
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            var cookieManager = new RequestCookieManager(Request.Cookies);
            string authenticationId = cookieManager.GetAuthenticationId();
            string sessionId = cookieManager.GetSessionId();

            var loginService = new LoginService();
            if (!string.IsNullOrEmpty(authenticationId))
            {
                LoginResponse response = loginService.Validate(sessionId, authenticationId);
                if (response == null || !response.IsSuccess)
                    Response.Redirect("~/Login.aspx" + "?redirect=" + Request.RawUrl);
            }
            else
            {
                Response.Redirect("~/Login.aspx" + "?redirect=" + Request.RawUrl);
            }
            if (Configuration.SSLEnabled)
            {
                if (!Request.IsLocal && !Request.IsSecureConnection)
                {
                    string redirectUrl = Request.Url.ToString().Replace("http:", "https:");
                    Response.Redirect(redirectUrl);
                }
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string signed_data = Request["signed_request"];

            if (!string.IsNullOrEmpty(signed_data))
            {
                var cookieManager = new RequestCookieManager(Request.Cookies);
                string sessionId = cookieManager.GetSessionId();
                //Get data.
                string[] splitPayload = signed_data.Split('.');
                string sig = splitPayload[0];
                string payload = splitPayload[1];
                Dictionary<string, string> decodedObj = SignedRequestManager.DecodePayload(payload);
                var loginService = new LoginService();
                if (!string.IsNullOrEmpty(decodedObj["user_id"]))
                {
                    RegisterResponse registerResponse = loginService.RegisterSocial(sessionId, decodedObj["user_id"],
                                                                                    "facebook",
                                                                                    decodedObj["email"],
                                                                                    decodedObj["first_name"],
                                                                                    decodedObj["last_name"],
                                                                                    decodedObj["phone"]);
                    if (registerResponse != null && registerResponse.IsSuccess)
                    {
                        string lastPage = cookieManager.GetLastPage();
                        if (!string.IsNullOrEmpty(lastPage))
                            Response.Redirect(lastPage);
                        else
                            Response.Redirect("~/Home.aspx");
                    }
                }
            }
        }
Example #3
0
 protected void btnLogin_Click(object sender, EventArgs e)
 {
     var username = txtUsername.Value;
     var password = txtPassword.Value;
     var clientCookie = new RequestCookieManager(Request.Cookies);
     var sessionId = clientCookie.GetSessionId();
     ILoginService loginService = new LoginService();
     var adminAccount = loginService.LoginAdmin(sessionId, username, password);
     if (adminAccount != null && adminAccount.IsSuccess)
     {
         var session = clientCookie.GetSession();
         session.AuthId = adminAccount.AuthenticationId;
         var cookieManager = new ResponseCookieManager(Response.Cookies);
         cookieManager.SetSessionData(session);
         Response.Redirect(string.Format("./{0}.aspx", adminAccount.DefaultPage));
     }
 }
Example #4
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            string postData = PostData;
            var cookieManager = new RequestCookieManager(Request.Cookies);

            var billingAddress = cookieManager.GetBillingAddress();
            var sessionId = cookieManager.GetSessionId();
            var authenticationId = cookieManager.GetAuthenticationId();
            if (string.IsNullOrEmpty(authenticationId) || string.IsNullOrEmpty(sessionId) || billingAddress == null)
            {
                RedirectToPreviousPage();
            }
            else
            {
                var isOfflineBooking = cookieManager.IsOfflineBooking;
                var voucherCode = cookieManager.GetVoucherCode();
                if (isOfflineBooking)
                {
                    var token = cookieManager.GetToken();
                    if (token == null)
                    {
                        RedirectToPreviousPage();
                    }
                    else
                    {
                        var isOfflineDataSet = SetOfflineParametersInSession(sessionId, authenticationId, token, voucherCode);
                        if (isOfflineDataSet == false)
                        {
                            RedirectToPreviousPage();
                        }
                    }
                }
                var paymentService = new PaymentService();
                postData = paymentService.GetPostData(authenticationId, sessionId, billingAddress);
            }

            Response.Clear();
            Response.Write(postData);
            Response.End();
        }
Example #5
0
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            var cookieManager = new RequestCookieManager(Request.Cookies);
            string authenticationId = cookieManager.GetAuthenticationId();
            string sessionId = cookieManager.GetSessionId();

            var loginService = new LoginService();
            if (string.IsNullOrEmpty(authenticationId) == false)
            {
                var pageName = Path.GetFileNameWithoutExtension(Request.PhysicalPath);
                var isAuthorized = loginService.IsAuthorized(sessionId, authenticationId, pageName);
                if (isAuthorized == false)
                {
                    Response.Redirect("~/Admin/AdminLogin.aspx");
                }
            }
            else
            {
                Response.Redirect("~/Admin/AdminLogin.aspx");
            }
        }
        protected override void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var header = Request.Headers.ToString();
                Logger.LogMessage(new Log("Headers", header, "PaymentResponse.aspx"));
                Logger.LogMessage(new Log("FormData", Request.Form.ToString(), "PaymentResponse.aspx"));
                Logger.LogMessage(new Log("QueryString", Request.QueryString.ToString(), "PaymentResponse.aspx"));

            }
            catch (Exception)
            {
            }
            base.Page_Load(sender, e);

            string response = Request.QueryString["DR"];
            var provider = "EBS";
            var variables = Request.QueryString;
            if (string.IsNullOrEmpty(response))
            {
                //Check PayU
                response = Request.Form["hash"];
                provider = "PayU";
                variables = Request.Form;
            }

            var cookieManager = new RequestCookieManager(Request.Cookies);

            var sessionId = cookieManager.GetSessionId();
            var authenticationId = cookieManager.GetAuthenticationId();
            var isOfflineBooking = cookieManager.IsOfflineBooking;
            var voucherCode = cookieManager.GetVoucherCode();

            if (!string.IsNullOrEmpty(response) && !string.IsNullOrEmpty(sessionId))
            {
                var paymentService = new PaymentService();
                string errorMessage;
                if (!paymentService.ValidateResponse(response, provider, authenticationId, sessionId, variables, voucherCode,
                                                         out errorMessage))
                {
                    Response.Write(errorMessage);
                    Response.End();
                }
                else
                {
                    if (isOfflineBooking == false)
                    {
                        var travelService = new TravelService();
                        BookResponse bookResponse = travelService.Book(sessionId, authenticationId);
                        if (bookResponse != null && bookResponse.IsSuccess)
                        {
                            HttpContext.Current.Response.Redirect("Confirm.aspx");
                        }
                        else
                        {
                            string error = bookResponse == null
                                               ? string.Empty
                                               : "Error: " + bookResponse.ErrorMessage;
                            HttpContext.Current.Response.Redirect("BookingFailed.aspx?error=" + error);
                        }
                    }
                    else
                    {
                        HttpContext.Current.Response.Redirect("OfflinePaymentConfirm.aspx");
                    }
                }
            }
            else
            {
                Response.Write("Sorry, invalid response received. Please login again and restart.");
                Response.End();
            }
        }