public ActionResult Login(Login l, string ReturnUrl = "/")
 {
     if (ModelState.IsValid)
     {
         MyMembershipProvider membership = new MyMembershipProvider();
         bool isValidUser = membership.ValidateUser(l.Username, l.Password);
         if (isValidUser)
         {
             UserDetail user = null;
             using (FormsAuthDBEntities dc = new FormsAuthDBEntities())
             {
                 user = dc.UserDetails.Where(a => a.UserName.Equals(l.Username)).FirstOrDefault();
             }
             if (user != null)
             {
                 JavaScriptSerializer js          = new JavaScriptSerializer();
                 string data                      = js.Serialize(user);
                 FormsAuthenticationTicket ticket = new FormsAuthenticationTicket
                                                        (1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), l.RememberMe, data);
                 string     encToken     = FormsAuthentication.Encrypt(ticket);
                 HttpCookie authoCookies = new HttpCookie(FormsAuthentication.FormsCookieName, encToken);
                 Response.Cookies.Add(authoCookies);
                 return(Redirect(ReturnUrl));
             }
         }
     }
     ModelState.Remove("Password");
     return(View());
 }
Beispiel #2
0
 public Account(IEmailSender emailSender,
                IConfigurationKeyRepository configRepo,
                ITextBuilder txtBuilder,
                IUserRepository userRepo,
                ISessionHelper sessionRepo)
 {
     myMembershipProvider = new MyMembershipProvider();
     sender      = emailSender;
     repoConfig  = configRepo;
     textBuilder = txtBuilder;
     repoUser    = userRepo;
     repoSession = sessionRepo;
 }
Beispiel #3
0
        protected override void Initialize(RequestContext requestContext)
        {
            if (FormsService == null)
            {
                FormsService = new FormsAuthenticationService();
            }
            MyMembershipProvider provider = new MyMembershipProvider();

            if (MembershipService == null)
            {
                MembershipService = new AccountMembershipService(provider);
            }

            base.Initialize(requestContext);
        }
 protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
 {
     MyMembershipProvider mmp=new MyMembershipProvider();
     MembershipCreateStatus mcs = new MembershipCreateStatus();
     mmp.CreateUser("", "", "", "", "", true, null, out mcs);
 }