2007-02-26 Igor Zelmanovich <igorz@mainsoft.com>
authorIgor Zelmanovich <igorz@mono-cvs.ximian.com>
Mon, 26 Feb 2007 09:59:57 +0000 (09:59 -0000)
committerIgor Zelmanovich <igorz@mono-cvs.ximian.com>
Mon, 26 Feb 2007 09:59:57 +0000 (09:59 -0000)
* Login.cs: fixed:
considers FormsAuthentication.ReturnUrl only if is placed in
the login page defined in web.config.

svn path=/trunk/mcs/; revision=73418

mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
mcs/class/System.Web/System.Web.UI.WebControls/Login.cs

index fbbc0e87a0316f7ec44ef3a0dda15b63faa78b25..ca9eb74694687f94417627d8b8e3546907efc704 100644 (file)
@@ -1,3 +1,9 @@
+2007-02-26 Igor Zelmanovich <igorz@mainsoft.com>
+
+       * Login.cs: fixed:
+       considers FormsAuthentication.ReturnUrl only if is placed in 
+       the login page defined in web.config. 
+
 2007-02-23  Marek Habersack  <grendello@gmail.com>
 
        * ObjectDataSourceView.cs: Fix saving/restoring the view state.
index 74b8dd76b42394637cc27a27f72af25ad2c8bf93..c86d20c6e0a0534256d14ea28ec6f4253f509e42 100644 (file)
@@ -1272,19 +1272,25 @@ namespace System.Web.UI.WebControls {
                                OnLoggedIn (EventArgs.Empty);
 
                                string url = DestinationPageUrl;
-                               if (Page.Request.Path.ToLower ().StartsWith (FormsAuthentication.LoginUrl.ToLower ()) &&
-                                       FormsAuthentication.ReturnUrl != null && 
-                                       FormsAuthentication.ReturnUrl.Length > 0)
-                                       Redirect (FormsAuthentication.ReturnUrl);
-                               if (url.Length == 0 && FormsAuthentication.DefaultUrl != null)
-                                       url = FormsAuthentication.DefaultUrl;
-                               if (url.Length == 0) {
-                                       Redirect (FormsAuthentication.LoginUrl);
-                               } else {
+                               if (Page.Request.Path.ToLower ().StartsWith (FormsAuthentication.LoginUrl.ToLower ())) {
+                                       if (!String.IsNullOrEmpty (FormsAuthentication.ReturnUrl))
+                                               Redirect (FormsAuthentication.ReturnUrl);
+                                       else if (!String.IsNullOrEmpty (DestinationPageUrl))
+                                               Redirect (url);
+                                       else if (!String.IsNullOrEmpty (FormsAuthentication.DefaultUrl))
+                                               Redirect (FormsAuthentication.DefaultUrl);
+                                       else if (url.Length == 0)
+                                               Refresh ();
+                               }
+                               else if (!String.IsNullOrEmpty (DestinationPageUrl)) {
                                        Redirect (url);
                                }
+                               else {
+                                       Refresh ();
+                               }
                                return true;
-                       } else {
+                       }
+                       else {
                                OnLoginError (EventArgs.Empty);
                                if (FailureAction == LoginFailureAction.RedirectToLoginPage) {
                                        // login page is defined in web.config
@@ -1326,6 +1332,11 @@ namespace System.Web.UI.WebControls {
                        if ((Page != null) && (Page.Response != null))
                                Page.Response.Redirect (url);
                }
+               
+               private void Refresh () {
+                       if ((Page != null) && (Page.Response != null))
+                               Page.Response.Redirect (Page.Request.RawUrl);
+               }
 
                private void UserName_TextChanged (object sender, EventArgs e)
                {