public ActionResult Create(Journal journal)
        {
            if (ModelState.IsValid)
            {
                db.Journals.AddObject(journal);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(journal));
        }
        public ActionResult Create(Article article)
        {
            if (ModelState.IsValid)
            {
                article.Body = Sanitizer.GetSafeHtml(article.Body);
                db.Articles.AddObject(article);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(article));
        }
Esempio n. 3
0
        public override bool ChangePassword(string username, string oldPwd, string newPwd)
        {
            if (!ValidateUser(username, oldPwd))
            {
                return(false);
            }

            ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, newPwd, true);

            OnValidatingPassword(args);

            if (args.Cancel)
            {
                throw args.FailureInformation ?? new MembershipPasswordException("Change password canceled due to new password validation failure.");
            }

            using (GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer(connectionString))
            {
                User user = GetUser(container, username, EncodePassword(oldPwd));

                if (user == null)
                {
                    return(false);
                }

                user.LoginCredentials.Password = EncodePassword(newPwd);
                container.AcceptAllChanges();
                container.SaveChanges();
                return(true);
            }
        }
Esempio n. 4
0
 public override bool DeleteUser(string username, bool deleteAllRelatedData)
 {
     using (GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer(connectionString))
     {
         User user = (from u in container.Users where u.LoginCredentials.UserName == username select u).FirstOrDefault();
         if (user == null)
         {
             return(false);
         }
         container.DeleteObject(user.LoginCredentials);
         container.DeleteObject(user);
         container.AcceptAllChanges();
         return(container.SaveChanges() > 0);
     }
 }
Esempio n. 5
0
        public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPwdQuestion, string newPwdAnswer)
        {
            if (!ValidateUser(username, password))
            {
                return(false);
            }

            using (GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer(connectionString))
            {
                User user = GetUser(container, username, password);
                user.LoginCredentials.PasswordQuestion = newPwdQuestion;
                user.LoginCredentials.PasswordAnswer   = newPwdAnswer;
                container.AcceptAllChanges();
                return(container.SaveChanges() > 0);
            }
        }
 public override bool DeleteUser( string username, bool deleteAllRelatedData )
 {
     using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
     {
         User user = (from u in container.Users where u.LoginCredentials.UserName == username select u).FirstOrDefault();
         if( user == null ) return false;
         container.DeleteObject( user.LoginCredentials );
         container.DeleteObject( user );
         container.AcceptAllChanges();
         return container.SaveChanges() > 0;
     }
 }
        public override bool ChangePasswordQuestionAndAnswer( string username, string password, string newPwdQuestion, string newPwdAnswer )
        {
            if( !ValidateUser( username, password ) ) return false;

            using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
            {
                User user = GetUser( container, username, password );
                user.LoginCredentials.PasswordQuestion = newPwdQuestion;
                user.LoginCredentials.PasswordAnswer = newPwdAnswer;
                container.AcceptAllChanges();
                return container.SaveChanges() > 0;
            }
        }
        public override bool ChangePassword( string username, string oldPwd, string newPwd )
        {
            if( !ValidateUser( username, oldPwd ) ) return false;

            ValidatePasswordEventArgs args = new ValidatePasswordEventArgs( username, newPwd, true );
            OnValidatingPassword( args );

            if( args.Cancel )
                throw args.FailureInformation ?? new MembershipPasswordException( "Change password canceled due to new password validation failure." );

            using( GhostmonkMainSiteModelContainer container = new GhostmonkMainSiteModelContainer( connectionString ) )
            {
                User user = GetUser( container, username, EncodePassword( oldPwd ) );

                if( user == null ) return false;

                user.LoginCredentials.Password = EncodePassword( newPwd );
                container.AcceptAllChanges();
                container.SaveChanges();
                return true;
            }
        }