Giter VIP home page Giter VIP logo

Comments (5)

jgauffin avatar jgauffin commented on August 29, 2024

Hmm. The MembershipProvider (MS design) has an event (OnValidatingPassword) which can return an exception which should be thrown. So to follow that I also throw an exception when my password strategy validation fails.

It's used both in the CreateUser and ResetPassword methods. But since there is a status code for it, I should maybe catch the exception internally and return the status code instead (in CreateUser). Would be interesting to know how the SqlMembershipProvider does.

from griffin.mvccontrib.

tdekoekkoek avatar tdekoekkoek commented on August 29, 2024

Not sure what the best strategy is. The default implementation of the AccountController in MVC looks like this, so there is no catching an exception. I suppose adding try..catch would work just as well, though:

            // Attempt to register the user
            MembershipCreateStatus createStatus;

            Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);

            if (createStatus == MembershipCreateStatus.Success)
            {
                FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                return RedirectToAction("Index", "Home");
            }
            else
            {
                ModelState.AddModelError("", ErrorCodeToString(createStatus));
            }

from griffin.mvccontrib.

jgauffin avatar jgauffin commented on August 29, 2024

The novell SqlProvider both throws exceptions and returns the invalid code. I changed so that CreateUser will always return the invalid code, while ResetPassword can still throw exceptions. Will commit soon.

from griffin.mvccontrib.

jgauffin avatar jgauffin commented on August 29, 2024

I've updated nuget now

On Fri, Aug 17, 2012 at 2:29 PM, Trevor de Koekkoek <
[email protected]> wrote:

Not sure what the best strategy is. The default implementation of the
AccountController in MVC looks like this, so there is no catching an
exception. I suppose adding try..catch would work just as well, though:

        // Attempt to register the user
        MembershipCreateStatus createStatus;

        Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);

        if (createStatus == MembershipCreateStatus.Success)
        {
            FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
            return RedirectToAction("Index", "Home");
        }
        else
        {
            ModelState.AddModelError("", ErrorCodeToString(createStatus));
        }


Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-7816494.

from griffin.mvccontrib.

tdekoekkoek avatar tdekoekkoek commented on August 29, 2024

Thanks. Great project by the way! I'll have to dig into the other contrib
projects and see what they offer.

-Trevor

On Fri, Aug 17, 2012 at 8:54 AM, Jonas Gauffin [email protected]:

I've updated nuget now

On Fri, Aug 17, 2012 at 2:29 PM, Trevor de Koekkoek <
[email protected]> wrote:

Not sure what the best strategy is. The default implementation of the
AccountController in MVC looks like this, so there is no catching an
exception. I suppose adding try..catch would work just as well, though:

// Attempt to register the user
MembershipCreateStatus createStatus;

Membership.CreateUser(model.UserName, model.Password, model.Email, null,
null, true, null, out createStatus);

if (createStatus == MembershipCreateStatus.Success)
{
FormsAuthentication.SetAuthCookie(model.UserName, false /*
createPersistentCookie */);
return RedirectToAction("Index", "Home");
}
else
{
ModelState.AddModelError("", ErrorCodeToString(createStatus));
}


Reply to this email directly or view it on GitHub<
https://github.com/jgauffin/griffin.mvccontrib/issues/20#issuecomment-7816494>.


Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-7817005.

Trevor de Koekkoek
http://sincere.ly/tdekoekkoek

from griffin.mvccontrib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.