From 0d0fca7f894b1aadd4840d550b65183fc4a9c124 Mon Sep 17 00:00:00 2001 From: Wilmer Ricciotti Date: Mon, 12 Dec 2011 15:45:52 +0000 Subject: [PATCH] Matitaweb: changes to matitadaemon.ml to make it work with new secure user db. --- matitaB/matita/matitadaemon.ml | 37 ++++++++++++++-------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/matitaB/matita/matitadaemon.ml b/matitaB/matita/matitadaemon.ml index 6d71ec6bc..081ce3165 100644 --- a/matitaB/matita/matitadaemon.ml +++ b/matitaB/matita/matitadaemon.ml @@ -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 - ("" - ^ "Redirecting to Matita page...") - 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 + ("" + ^ "Redirecting to Matita page...") + with MatitaAuthentication.InvalidPassword -> cgi#set_header ~cache:`No_cache ~content_type:"text/html; charset=\"utf-8\"" (); cgi#out_channel#output_string - "Authentication error" - end; - + "Authentication error"); cgi#out_channel#commit_work() - ;; let logout (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) = -- 2.39.2