Commit cf5d746a authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Remove admin from web interface

parent 99736f1e
......@@ -65,7 +65,7 @@ let if_eligible f uuid x =
lwt () =
if election.Common.public_data.private_p then (
match user with
| Some (_, user) ->
| Some user ->
lwt eligible = Services.is_eligible uuid user in
if not eligible then forbidden () else return ()
| None -> forbidden ()
......@@ -86,10 +86,10 @@ let () = Eliom_registration.Html5.register
let () = Eliom_registration.Redirection.register
~service
~scope:Eliom_common.default_session_scope
(fun () (user_name, admin_p) ->
(fun () user_name ->
let user_type = "dummy" in
Eliom_reference.set Services.user
(Some (admin_p, {user_name; user_type})) >>
(Some {user_name; user_type}) >>
return Services.home)
in
Templates.dummy_login ~service)
......
......@@ -29,7 +29,7 @@ let perform_login () =
~csrf_safe:true
~csrf_scope:Eliom_common.default_session_scope
~fallback:login
~post_params:Eliom_parameter.(string "username" ** bool "admin_p")
~post_params:Eliom_parameter.(string "username")
()
let auth_systems = [
......@@ -38,7 +38,7 @@ let auth_systems = [
let user = Eliom_reference.eref
~scope:Eliom_common.default_session_scope
(None : (bool * user) option)
(None : user option)
let uuid = Eliom_parameter.user_type
(fun x -> match Uuidm.of_string x with
......
......@@ -54,7 +54,7 @@ let base ~title ~header ~content =
div ~a:[a_id "footer"] (
[span ~a:[a_style "float:right;"] [ (* footer logo *) ]] @
(match user with
| Some (admin_p, user) ->
| Some user ->
[pcdata "logged in as "] @ (format_user user 15) @ [
pcdata " [";
a ~service:Services.logout [pcdata "logout"] ();
......@@ -164,20 +164,8 @@ let index ~featured =
~header:[h2 [pcdata site_title]]
~content:(
let mystuff = match user with
| Some (admin_p, u) ->
let administered = if admin_p then Some [] else None in
| Some u ->
let voted = [] in
let administration_box = match administered with
| Some admin ->
let administered_box = match admin with
| _::_ -> ul (List.map format_one_election admin)
| [] -> em [pcdata "none yet"]
in [
h4 [pcdata "Administration"];
administered_box;
]
| None -> []
in
let recent_votes = [
h4 [pcdata "Recent votes"];
match voted with
......@@ -188,7 +176,7 @@ let index ~featured =
div ~a:[a_style "font-size:1.4em;"; a_class ["highlight-box"]]
(format_user u 25)
]
@ administration_box @ recent_votes
@ recent_votes
| None ->
[h3 [pcdata "Log In to Start Voting"]]
@ (login_box Services.auth_systems)
......@@ -218,16 +206,12 @@ let dummy_login ~service =
let form = post_form
~a:[a_id "login_form"; a_class ["prettyform"]]
~service
(fun (username_name, admin_name) ->
(fun username_name ->
[
tablex [tbody [
tr [
th [label ~a:[a_for username_name] [pcdata "Username:"]];
td [string_input ~a:[a_maxlength 50] ~input_type:`Text ~name:username_name ()];
];
tr [
th [label ~a:[a_for admin_name] [pcdata "Admin?"]];
td [bool_checkbox ~name:admin_name ()];
]]
];
div [
......@@ -254,7 +238,7 @@ let election_view ~election ~user =
a ~service:Services.login [pcdata "Log in"] ();
pcdata " to check if you can vote.";
]
| Some (_, u) ->
| Some u ->
lwt b = Services.is_eligible election.Common.election.e_uuid u in
let can = if b then pcdata "can" else pcdata "cannot" in
Lwt.return [
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment