예제 #1
0
 public User CreateUser(User user, string password)
 {
     if (user.Type == UserType.TenderOwner)
         return CreateTenderOwner(user as TenderOwnerUser, password);
     else if (user.Type == UserType.TenderAttendee)
         return CreateTenderAttendee(user as TenderAttendeeUser, password);
     else if (user.Type == UserType.Administrator)
         throw new NotImplementedException();
     else
         throw new ArgumentException("Invalid user type");
 }
        public void OnLogin(User user, bool isPersistent)
        {
            CurrentUser = user;

            FormsAuthentication.SetAuthCookie(user.Name, isPersistent);

            UserType type = user.Type;

            var ticket = new FormsAuthenticationTicket(1, user.Name, DateTime.Now, DateTime.Now.AddMilliseconds(FormsAuthentication.Timeout.TotalMilliseconds), false, ((int)type).ToString());
            var encryptedTicket = FormsAuthentication.Encrypt(ticket);
            var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)
            {
                Domain = FormsAuthentication.CookieDomain,
                HttpOnly = true,
                Secure = FormsAuthentication.RequireSSL,
            };

            Response.AppendCookie(authCookie);
        }