示例#1
0
        protected void ChangeButton_Click(object sender, EventArgs e)
        {
            string oldPassword        = old_password.Value.ToString();
            string newPassword        = new_password.Value.ToString();
            string newPasswordConfirm = password_confirm.Value.ToString();

            string        uName     = Session["uName"].ToString();
            List <string> errorList = new List <string>();

            int wrong = 0;

            if (newPassword != newPasswordConfirm)
            {
                errorList.Add("New password didn't match");

                wrong = 1;
            }



            if (LoginAndRegisterController.tryLogin(uName, oldPassword) && wrong == 0)
            {
                UserService.changePassword(newPassword, UserService.getUserByName(uName).FirstOrDefault().UserId);
                Session["message"] = "Password Change Success";
                Response.Redirect("Home.aspx");
            }
            else
            {
                errorList.Add("Old Password didn't match");
            }
            Session["error"] = errorList;
            Response.Redirect("Profile.aspx");
        }
        protected void Submit_Click(object sender, EventArgs e)
        {
            string uName = username.Value.ToString();
            string pass  = password.Value.ToString();

            if (LoginAndRegisterController.tryLogin(uName, pass))
            {
                FP_ONLINEREP.User result = UserService.getUserByNameOrEmail(uName, uName);
                Session["uName"]     = uName;
                Session["UId"]       = result.UserId;
                Session["Authority"] = result.Authority;
                Response.Redirect("Login.aspx", true);
            }
            else
            {
                errorLabel.Text = "Wrong Username or Password";
            }
        }