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) =