using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace AppliWebANA.Controllers {
	public class SecuriteController : Controller {
		[HttpGet]
		public ActionResult Index() {
			return View();
		}
		[HttpPost]
		public ActionResult Index(string nom, string mdp, string returnUrl) {
			if( Request.Form.AllKeys.Contains( "creer" ) ) {
				MembershipCreateStatus status;
				Membership.CreateUser( nom, mdp, "ezeze@zeze.com", "q", "r", true, out status );
				return View();
			}
			else {
				if( Membership.ValidateUser( nom, mdp ) ) {
					FormsAuthentication.SetAuthCookie( nom, false );
					return Redirect( returnUrl );
				}
				else
					return View();
			}
		}
	}
}