protected void btnChange_Click(object sender, EventArgs e)
    {
        string oldPassword = AccountFunctions.getMd5Hash(txtOldPassword.Text);
        string newPassword = AccountFunctions.getMd5Hash(txtNewPassword.Text);

        lblResult.Text = ConnectionClass.ChangePassword((string)Session["login"], oldPassword, newPassword);
    }
    protected void btnChange_Click(object sender, EventArgs e)
    {
        //user exists?

        string who = txtName.Text;

        who = who.Replace("'", "");
        who = who.Replace("\"", "");

        User user = ConnectionClass.GetUserDetails(who);

        if (user == null)
        {
            lblResult.Text = "User does not exist!";
        }
        else
        {
            string activationCode = Membership.GeneratePassword(12, 1);
            activationCode = Regex.Replace(activationCode, "[^0-9A-Za-z]+", ",");
            DateTime dateCodeSent = DateTime.Now;
            ConnectionClass.UpdateCode(user.name, activationCode, dateCodeSent);
            AccountFunctions.SendEmailRecoverPassword(user.name, user.email, activationCode, Server.MapPath("../../Images/"));
            lblResult.Text = "Please verify your inbox for the recovery link!";
        }
    }
        public async Task <ActionResult> Login(AuthVm model)
        {
            var response = await AccountFunctions.Login(model.Email, model.Password, model.IsRemember);

            if (response.Code == (int)EnumList.Response.Success)
            {
                Notification.Success = response.Message;

                if (Url.IsLocalUrl(model.ReturnUrl))
                {
                    return(Redirect(model.ReturnUrl));
                }
                return(RedirectToAction("Index", "Dashboard"));
            }

            if (response.Message.Equals("Lockout", StringComparison.InvariantCultureIgnoreCase))
            {
                return(View("Lockout", new LockoutVm {
                    Email = model.Email, UnlockDate = response.LockOutDateTime
                }));
            }

            if (response.Message.Equals("You need to confirm your email.", StringComparison.InvariantCultureIgnoreCase))
            {
                StaticValues.NotifyActionRequiredMsg =
                    "Your email address is not verified. Please, <a href=# class=\"alert-link\">click here</a>, to verify your account.";
            }
            else
            {
                StaticValues.NotifyError = response.Message;
            }

            return(View("Index", model));
        }
Beispiel #4
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string password = AccountFunctions.getMd5Hash(txtPassword.Text);

        string whatEmail = txtLogin.Text;

        whatEmail = whatEmail.Replace("'", "");
        whatEmail = whatEmail.Replace("\"", "");

        User user = ConnectionClass.LoginUser(whatEmail, password);

        if (user != null)
        {
            bool activated = ConnectionClass.accountActivated(user.email);

            if (activated == true)
            {
                //Store login variables in session
                Session["login"] = user.name;
                Session["type"]  = user.type;
                Response.Redirect("~/Pages/Home.aspx");
            }

            else
            {
                string where = "~/Pages/Account/Activation.aspx?user="******"&code=null";
                Response.Redirect(where);
            }
        }
        else
        {
            lblError.Text = "Login failed";
        }
    }
Beispiel #5
0
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        if (Page.IsValid == true && IsReCaptchValid())
        {
            string whatEmail = txtEmail.Text;
            whatEmail = whatEmail.Replace("'", "");
            whatEmail = whatEmail.Replace("\"", "");

            string whatName = txtName.Text;
            whatName = whatName.Replace("'", "");
            whatName = whatName.Replace("\"", "");

            string password = AccountFunctions.getMd5Hash(txtPassword.Text);

            //Create a new user
            User user = new User(whatName, password, whatEmail, "user");

            string activationCode = Membership.GeneratePassword(12, 1);
            activationCode = Regex.Replace(activationCode, "[^0-9A-Za-z]+", ",");
            DateTime dateCodeSent = DateTime.Now;

            //Register the user and return a result message
            lblResult.Text = ConnectionClass.RegisterUser(user, activationCode, dateCodeSent);

            if (lblResult.Text == "User registered! Please check your e-mail for the activation link.")
            {
                AccountFunctions.SendEmailActivateAccount(user.name, user.email, activationCode, Server.MapPath("../../Images/"));
            }
        }
    }
        public async Task <ActionResult> Index(string returnUrl, string userId, string code)
        {
            var model = new AuthVm {
                ReturnUrl = returnUrl
            };

            if (string.IsNullOrWhiteSpace(userId) || string.IsNullOrWhiteSpace(code))
            {
                return(View(model));
            }
            await AccountFunctions.ConfirmEmail(userId, code);

            return(View(model));
        }
Beispiel #7
0
    protected void lBtnCodeRequest_Click(object sender, EventArgs e)
    {
        //generate new code
        string activationCode = Membership.GeneratePassword(12, 1);

        activationCode = Regex.Replace(activationCode, "[^0-9A-Za-z]+", ",");
        DateTime dateCodeSent = DateTime.Now;

        ConnectionClass.UpdateCode(Request.QueryString["user"], activationCode, dateCodeSent);
        lBtnCodeRequest.Visible = false;
        lblResult.Text          = "A new activation link was sent to you!";
        User user = ConnectionClass.GetUserDetails(Request.QueryString["user"]);

        AccountFunctions.SendEmailActivateAccount(user.name, user.email, activationCode, Server.MapPath("../../Images/"));
    }
Beispiel #8
0
    protected void btnChange_Click(object sender, EventArgs e)
    {
        //get variables from URL
        string linkClient = Request.QueryString["user"];
        string linkCode   = Request.QueryString["code"];

        //retrieve code & date from DB
        DateTime dateSent = new DateTime();
        string   code = "", email = "";

        ConnectionClass.DateCodeActivateAccount(linkClient, ref dateSent, ref code, ref email);

        if (code == linkCode && DateTime.Now <= dateSent.AddDays(3))
        {
            lblResult.Text = ConnectionClass.ChangeForgottenPassword(linkClient, AccountFunctions.getMd5Hash(txtNewPassword.Text));
        }
        else
        {
            lblResult.Text = "The link has expired or is wrong!";
        }
    }
 protected void btnSubmit_Personal_Click(object sender, EventArgs e)
 {
     AccountFunctions.checkUserInput_Personal(txtFirstName, txtLastName, txtAddress, txtCity, statesList, txtZip, txtPhone);
 }
Beispiel #10
0
 protected void btnSubmit_Password_Click(object sender, EventArgs e)
 {
     AccountFunctions.checkUserInput_Password(txtOldPass, txtNewPass, txtRetype);
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     SessionFunctions.validateLogin();
     AccountFunctions.loadAccountData(welcomeLabel, firstNameLabel, lastNameLabel, usernameLabel, emailLabel, addressLabel1, addressLabel2, phoneLabel);
 }
Beispiel #12
0
 protected void btnSubmit_Account_Click(object sender, EventArgs e)
 {
     AccountFunctions.checkUserInput_Account(txtEmail);
 }