Diff
Not logged in

Differences From:

File src/login.c part of check-in [9e80dc66cf] - Use sqlite3_snprintf() instead of snprintf() since the latter is not available on all platforms. by drh on 2008-10-18 13:03:36. [view]

To:

File src/login.c part of check-in [0600b278c0] - Remove the unused inherit-anon configuration attribute. Fix the automatic redirect that follows a login operation. Fix "config push user" on the server side. by drh on 2008-10-26 21:30:23. [view]

@@ -67,15 +67,28 @@
   return zCookieName;
 }
 
 /*
+** Redirect to the page specified by the "g" query parameter.
+** Or if there is no "g" query parameter, redirect to the homepage.
+*/
+static void redirect_to_g(void){
+  const char *zGoto = P("g");
+  if( zGoto ){
+    cgi_redirect(zGoto);
+  }else{
+    fossil_redirect_home();
+  }
+}
+
+/*
 ** WEBPAGE: /login
 ** WEBPAGE: /logout
 **
 ** Generate the login page
 */
 void login_page(void){
-  const char *zUsername, *zPasswd, *zGoto;
+  const char *zUsername, *zPasswd;
   const char *zNew1, *zNew2;
   const char *zAnonPw = 0;
   int anonFlag;
   char *zErrMsg = "";
@@ -82,14 +95,13 @@
 
   login_check_credentials();
   zUsername = P("u");
   zPasswd = P("p");
-  zGoto = PD("g","index");
   anonFlag = P("anon")!=0;
   if( P("out")!=0 ){
     const char *zCookieName = login_cookie_name();
     cgi_set_cookie(zCookieName, "", 0, -86400);
-    cgi_redirect(zGoto);
+    redirect_to_g();
   }
   if( g.okPassword && zPasswd && (zNew1 = P("n1"))!=0 && (zNew2 = P("n2"))!=0 ){
     if( db_int(1, "SELECT 0 FROM user"
                   " WHERE uid=%d AND pw=%Q", g.userUid, zPasswd) ){
@@ -110,9 +122,9 @@
     }else{
       db_multi_exec(
          "UPDATE user SET pw=%Q WHERE uid=%d", zNew1, g.userUid
       );
-      cgi_redirect(zGoto);
+      redirect_to_g();
       return;
     }
   }
   if( zUsername!=0 && zPasswd!=0 && zPasswd[0]!=0 ){
@@ -143,9 +155,9 @@
           "  cexpire=julianday('now')+%d/86400.0 WHERE uid=%d",
           zCookie, zIpAddr, expires, uid
         );
       }
-      cgi_redirect(zGoto);
+      redirect_to_g();
     }
   }
   style_header("Login/Logout");
   @ %s(zErrMsg)
@@ -324,14 +336,14 @@
   static char *zDev = 0;
   int i;
   for(i=0; zCap[i]; i++){
     switch( zCap[i] ){
-      case 's':   g.okSetup = 1;
+      case 's':   g.okSetup = 1;  /* Fall thru into Admin */
       case 'a':   g.okAdmin = g.okRdTkt = g.okWrTkt =
                               g.okRdWiki = g.okWrWiki = g.okNewWiki =
                               g.okApndWiki = g.okHistory = g.okClone =
                               g.okNewTkt = g.okPassword = g.okRdAddr =
-                              g.okTktFmt = 1;
+                              g.okTktFmt = 1;  /* Fall thru into Read/Write */
       case 'i':   g.okRead = g.okWrite = 1;                     break;
       case 'o':   g.okRead = 1;                                 break;
       case 'z':   g.okZip = 1;                                  break;