Reputation: 25
I'm creating a shopping cart using google checkout api.
I what to submit the form of the hidden fields only if the user is autenticated to the site.
How can I force (or redirect to login) authentication before submitting the form to google checkout?
Upvotes: 1
Views: 90
Reputation: 63512
decorating your action method with the [Authorize]
attribute should do it
[Authorize]
public ActionResult Cart()
{
...
}
[Authorize]
[HttpPost]
public ActionResult Cart(CartModel model)
{
...
}
by default the user will get kicked out to your Log In page if you've defined one
Upvotes: 3
Reputation: 13934
Something like this:
[HttpPost]
public ActionResult CheckOut(Cart cart)
{
if (User.Identity.IsAuthenticated)
{
//go checkout
}
else
{
//redirect
}
}
Upvotes: 0