If forced to log in to access the site, set redirect so we go back to the page
[cocanwiki.git] / scripts / login.ml
index 4b55be7..4594e6b 100644 (file)
@@ -1,7 +1,7 @@
 (* COCANWIKI - a wiki written in Objective CAML.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * Copyright (C) 2004 Merjis Ltd.
- * $Id: login.ml,v 1.6 2005/03/31 14:24:04 rich Exp $
+ * $Id: login.ml,v 1.7 2005/11/21 15:28:35 rich Exp $
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -66,7 +66,17 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
       else
        Cookie.cookie "auth" cookie ~path:"/" in
 
-    ok ~title:"Logged in" ~buttons:[ok_button redirect] ~cookie
+    let ok_button = ok_button redirect in
+    let buttons =
+      if redirect <> "/" && redirect <> "/index" then (
+       ok_button ::
+         [ { Template.StdPages.label = " Home Page ";
+             Template.StdPages.link = "/";
+             Template.StdPages.method_ = None;
+             Template.StdPages.params = [] } ]
+      ) else [ ok_button ] in
+
+    ok ~title:"Logged in" ~buttons ~cookie
       q ("Welcome " ^ username ^ "." ^
         if force_password_change then "  Please change your password now."
         else "")