]> matita.cs.unibo.it Git - helm.git/commitdiff
Matitaweb: changes to matitadaemon.ml to make it work with new secure user db.
authorWilmer Ricciotti <ricciott@cs.unibo.it>
Mon, 12 Dec 2011 15:45:52 +0000 (15:45 +0000)
committerWilmer Ricciotti <ricciott@cs.unibo.it>
Mon, 12 Dec 2011 15:45:52 +0000 (15:45 +0000)
matitaB/matita/matitadaemon.ml

index 6d71ec6bc4f63c7b89d438da264f3b40e2ca3811..081ce316538b6563bf38b55650cf1b13e7f458f2 100644 (file)
@@ -561,34 +561,27 @@ let login (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) =
   assert (cgi#arguments <> []);
   let uid = cgi#argument_value "userid" in
   let userpw = cgi#argument_value "password" in
-  let pw,_ = MatitaAuthentication.lookup_user uid in
-
-  if pw = userpw then
-   begin
-   let ft = MatitaAuthentication.read_ft uid in
-   let _ = MatitaFilesystem.html_of_library uid ft in
-    let sid = MatitaAuthentication.create_session uid in
-    (* let cookie = Netcgi.Cookie.make "session" (Uuidm.to_string sid) in
-       cgi#set_header ~set_cookies:[cookie] (); *)
-    env#set_output_header_field 
-      "Set-Cookie" ("session=" ^ (Uuidm.to_string sid));
-(*    env#set_output_header_field "Location" "/index.html" *)
-    cgi#out_channel#output_string
-     ("<html><head><meta http-equiv=\"refresh\" content=\"2;url=/index.html\">"
-     ^ "</head><body>Redirecting to Matita page...</body></html>")
-   end
-  else
-   begin
+  (try 
+      MatitaAuthentication.check_pw uid userpw;
+      let ft = MatitaAuthentication.read_ft uid in
+      let _ = MatitaFilesystem.html_of_library uid ft in
+       let sid = MatitaAuthentication.create_session uid in
+       (* let cookie = Netcgi.Cookie.make "session" (Uuidm.to_string sid) in
+          cgi#set_header ~set_cookies:[cookie] (); *)
+       env#set_output_header_field 
+         "Set-Cookie" ("session=" ^ (Uuidm.to_string sid));
+   (*    env#set_output_header_field "Location" "/index.html" *)
+       cgi#out_channel#output_string
+        ("<html><head><meta http-equiv=\"refresh\" content=\"2;url=/index.html\">"
+        ^ "</head><body>Redirecting to Matita page...</body></html>")
+  with MatitaAuthentication.InvalidPassword ->
     cgi#set_header
       ~cache:`No_cache 
       ~content_type:"text/html; charset=\"utf-8\""
       ();
     cgi#out_channel#output_string
-      "<html><head></head><body>Authentication error</body></html>"
-   end;
-    
+      "<html><head></head><body>Authentication error</body></html>");
   cgi#out_channel#commit_work()
-  
 ;;
 
 let logout (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) =