Esempio n. 1
0
        protected void ConfirmRecovery_ServerClick(object sender, EventArgs e)
        {
            string pass     = RegPass.Value;
            var    userName = ViewState["userName"].ToString();

            if (String.IsNullOrEmpty(userName))
            {
                LoginError.Text = "Ошибка при обработке запроса. Попробуйте еще раз";
                return;
            }
            var user   = new UserFull(userName);
            var genPas = Membership.GetUser(userName).ResetPassword();

            user.Change_Password(genPas, pass);
            Response.Redirect("/login");
            /*Deleting token from db, actually dont think that it is useful feature */
            using (var _connection = new SqlConnection(Global.WaifString))
            {
                _connection.Open();
                using (var cmd = new SqlCommand("DELETE From RecoveryToken WHERE UserId=(SELECT Id " +
                                                "WHERE Name=@UserName)", _connection))
                {
                    cmd.Parameters.AddWithValue("UserName", userName);
                    cmd.ExecuteNonQuery();
                }
            }
        }
Esempio n. 2
0
        protected void SaveAll_Click(object sender, EventArgs e)
        {
            if (Membership.GetUserNameByEmail(UserEmail.Value) == null)
            {
                user.Change_Email(UserEmail.Value);
            }
            if (Membership.GetUser(UserName.Value) == null)
            {
                user.Change_Login(UserName.Value);
            }
            if (OldPass.Value != "")
            {
                user.Change_Password(OldPass.Value, RegPass.Value);
            }
            user.Change_Description(wcomments.Value);
            user.Change_Name(UserRName.Value);
            user.Change_Url(UserUrl.Value);
            user.Change_Image(ImageSrc.Value);

            FormsAuthentication.SignOut();
            FormsAuthentication.SetAuthCookie(user.Login, true);
            Response.Redirect("/profile");
        }