Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Load user info
            var currentUser = Global.db.currentUser;

            if (currentUser != null)
            {
                var userSessionManager = new UserSessionManager();
                userSessionManager.LoadUserInfo(currentUser);
            }
            else
            {
                Response.Redirect("/Login");
            }

            //Get number of activated apps
            float ativatedApps = 0;

            foreach (var app in AppsList.InstalledApps)
            {
                if (app.enabled)
                {
                    ativatedApps += 1;
                }
            }

            if (Session["userPlan"].ToString() == "free")
            {
                float activatedAppsPercentage = ((ativatedApps / 3) * 100);
                enabledAppsCount.InnerText = ativatedApps.ToString() + " / 3";
                enabledAppsProgress.Attributes.Add("style", "width: " + activatedAppsPercentage + "%");
                if (activatedAppsPercentage >= 100)
                {
                    Session["userMaxAppsReached"] = true;
                }
                else
                {
                    Session["userMaxAppsReached"] = false;
                }
            }
            else
            {
                float activatedAppsPercentage = ((ativatedApps / AppsList.InstalledApps.Count) * 100);
                enabledAppsCount.InnerText = ativatedApps.ToString() + " / " + AppsList.InstalledApps.Count.ToString();
                enabledAppsProgress.Attributes.Add("style", "width: " + activatedAppsPercentage + "%");
                if (activatedAppsPercentage >= 100)
                {
                    Session["userMaxAppsReached"] = true;
                }
                else
                {
                    Session["userMaxAppsReached"] = false;
                }
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Hide login error
            txtLoginError.Visible = false;

            //Check if logging out
            if (Request.Params.Count > 0 && Request.Params["logout"] == "true")
            {
                Session.Abandon();
                Global.db.SignOut();
                Global.initializeFirebase();
                Response.Redirect("/Login");
            }

            //Redirect if already logged in
            if (Session["userID"] != null)
            {
                Response.Redirect("/Dashboard");
            }

            //If user is signing in
            if (Page.IsPostBack)
            {
                var userName = txtEmail.Value;
                var password = txtPassword.Value;

                var signedInUser = validateLogin(userName, password);
                if (signedInUser != null)
                {
                    UserSessionManager sessionMan = new UserSessionManager();
                    sessionMan.LoadUserInfo(signedInUser);

                    Response.Redirect("/Dashboard");
                }
                else
                {
                    txtLoginError.Visible = true;
                }
            }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["userID"] == null)
            {
                Response.Redirect("/Login");
            }

            txtPasswordError.Visible = false;

            if (Page.IsPostBack)
            {
                var payload = new
                {
                    firstName = txtFirstName.Value,
                    lastName  = txtLastName.Value,
                    business  = txtBusiness.Value,
                    phone     = txtPhone.Value,
                    website   = txtWebsite.Value
                };

                if (Global.db.WriteToDB("Users/" + Session["userID"], payload))
                {
                    UserSessionManager sessionMan = new UserSessionManager();
                    sessionMan.LoadUserInfo((User)Session["user"]);
                }

                //Reset password
                if (txtPasswordOld.Value.Trim() != "" && txtPasswordNew.Value.Trim() != "" && txtPasswordNewVerify.Value.Trim() != "")
                {
                    var oldPasword        = txtPasswordOld.Value.Trim();
                    var newPassword       = txtPasswordNew.Value.Trim();
                    var newPasswordVerify = txtPasswordNewVerify.Value.Trim();

                    if (newPassword != newPasswordVerify)
                    {
                        txtPasswordError.Visible   = true;
                        txtPasswordError.InnerText = "Passwords do not match";
                    }
                    else
                    {
                        var changedPassword = Global.db.ChangePassword(Session["userEmail"].ToString(), oldPasword, newPassword);
                        if (changedPassword == null)
                        {
                            txtPasswordError.Visible = true;
                        }
                    }
                }

                //Send Email
                var newEmail = new Model_Email
                {
                    email   = "*****@*****.**",
                    name    = "Patrick",
                    subject = "Settings have changed",
                    body    = "Thanks for creating an Landrick account. To continue, please confirm your email address by clicking the button below :"
                };
                EmailSender.SendEmail(newEmail, Server);
            }
            else
            {
                //Set current Values
                txtFirstName.Value = Session["userFirstName"].ToString();
                txtLastName.Value  = Session["userLastName"].ToString();
                txtEmail.Value     = Session["userEmail"].ToString();
                txtBusiness.Value  = Session["userBusiness"].ToString();
                txtPhone.Value     = Session["userPhone"].ToString();
                txtWebsite.Value   = Session["userWebsite"].ToString();
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Redirect if already logged in
            if (Session["userID"] != null)
            {
                Response.Redirect("/Dashboard");
            }

            if (Page.IsPostBack)
            {
                if (Request.QueryString["plan"] != null)
                {
                    Session["selectedPlan"] = Request.QueryString["plan"];
                }

                //Validate data
                if (firstName.Value == "")
                {
                    return;
                }
                if (lastName.Value == "")
                {
                    return;
                }
                if (emailAddress.Value == "")
                {
                    return;
                }
                if (password.Value == "")
                {
                    return;
                }

                var userFirstName = firstName.Value;
                var userLastName  = lastName.Value;
                var userEmail     = emailAddress.Value;
                var userPassword  = password.Value;

                //Proceed if debugging
                if (!Debugger.IsAttached)
                {
                    Response.Redirect("/Login");
                }

                var newUser = CreateCustomer_Firebase(userFirstName, userLastName, userEmail, userPassword);
                if (newUser == null)
                {
                    Response.Redirect("/Login");
                }
                if (!CreateCustomer_Stripe(newUser))
                {
                    Response.Redirect("/Login");
                }


                //All went well, load session data
                UserSessionManager sessionMan = new UserSessionManager();
                sessionMan.LoadUserInfo(newUser);

                //Redirect to dashboard
                Response.Redirect("/Dashboard");
            }
        }