Merge pull request #2735 from xmcclure/early-lookup-addr
[mono.git] / mcs / class / System.Web / System.Web.Security / FormsAuthentication.cs
index 3c5bbe4530b24be844168f3f42b3a492c78e5f04..491d74f6c4d49884b7a72f0fe70695f6c068871e 100644 (file)
@@ -69,7 +69,6 @@ namespace System.Web.Security
                                                "default.aspx",
                                                "index.html",
                                                "index.htm" };
-#if NET_4_0
                public static TimeSpan Timeout {
                        get; private set;
                }
@@ -92,7 +91,6 @@ namespace System.Web.Security
                        if (!String.IsNullOrEmpty (value))
                                default_url = value;
                }
-#endif
                public FormsAuthentication ()
                {
                }
@@ -215,22 +213,19 @@ namespace System.Web.Security
 
                        DateTime now = DateTime.Now;
                        DateTime then;
-                       if (createPersistentCookie)
-                               then = now.AddYears (50);
-                       else
-                               then = now.AddMinutes (timeout);
+                       if (createPersistentCookie)
+                               then = now.AddMinutes(timeout);
+                       else
+                               then = DateTime.MinValue;
 
                        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket (1,
                                                                                          userName,
                                                                                          now,
-                                                                                         then,
+                                              createPersistentCookie?then:now.AddYears (50),
                                                                                          createPersistentCookie,
                                                                                          String.Empty,
                                                                                          cookiePath);
 
-                       if (!createPersistentCookie)
-                               then = DateTime.MinValue;
-
                        HttpCookie cookie = new HttpCookie (cookieName, Encrypt (ticket), strCookiePath, then);
                        if (requireSSL)
                                cookie.Secure = true;
@@ -326,9 +321,7 @@ namespace System.Web.Security
                                FormsAuthenticationConfiguration config = section.Forms;
 
                                cookieName = config.Name;
-#if NET_4_0
                                Timeout = config.Timeout;
-#endif
                                timeout = (int)config.Timeout.TotalMinutes;
                                cookiePath = config.Path;
                                protection = config.Protection;
@@ -337,18 +330,14 @@ namespace System.Web.Security
                                cookie_domain = config.Domain;
                                cookie_mode = config.Cookieless;
                                cookies_supported = true; /* XXX ? */
-#if NET_4_0
                                if (!String.IsNullOrEmpty (default_url))
                                        default_url = MapUrl (default_url);
                                else
-#endif
                                        default_url = MapUrl(config.DefaultUrl);
                                enable_crossapp_redirects = config.EnableCrossAppRedirects;
-#if NET_4_0
                                if (!String.IsNullOrEmpty (login_url))
                                        login_url = MapUrl (login_url);
                                else
-#endif
                                        login_url = MapUrl(config.LoginUrl);
 
                                initialized = true;