From 10e45339e3ce35b4310a0743d490e9a43965c1f9 Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Tue, 24 Nov 2009 17:23:20 +0100 Subject: make ac dependent on user, not on realm --- access_control.rb | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) (limited to 'access_control.rb') diff --git a/access_control.rb b/access_control.rb index 40a4757..ae91317 100755 --- a/access_control.rb +++ b/access_control.rb @@ -44,35 +44,35 @@ File.open(".htdigest","r").each_line{|l| def write_htaccess(acusers) File.open(".htaccess","w"){|htaccess| - if acusers.values.include?("config") + if acusers.include?("admin") htaccess << < AuthType digest -AuthName "config" +AuthName "dudle" AuthUserFile "#{File.expand_path(".").gsub('"','\\\\"')}/.htdigest" -Require valid-user +Require user admin HTACCESS end - if acusers.values.include?("vote") + if acusers.include?("participant") htaccess << < Username: - + #{userarray[0]} - FORM @@ -140,7 +139,6 @@ end if $cgi.include?("ac_user") user = $cgi["ac_user"] - type = $cgi["ac_type"] if !(user =~ /^[\w]*$/) # add user usercreatenotice = "
Only uppercase, lowercase, digits are allowed in the username.
" @@ -148,17 +146,9 @@ if $cgi.include?("ac_user") usercreatenotice = "
Passwords did not match.
" else if $cgi.include?("ac_create") - case type - when "config" - add_to_htdigest(user, type, $cgi["ac_password0"]) - add_to_htdigest(user, "vote", $cgi["ac_password0"]) - acusers[user] = type - write_htaccess(acusers) - when "vote" - add_to_htdigest(user, type, $cgi["ac_password0"]) - acusers[user] = type - write_htaccess(acusers) - end + add_to_htdigest(user,$cgi["ac_password0"]) + acusers[user] = type + write_htaccess(acusers) end # delete user @@ -212,13 +202,13 @@ else admincreatenotice = usercreatenotice || "You will be asked for the password you entered here after pressing save!" - user = ["admin","config", + user = ["admin", "The user ‘admin’ has access to the vote as well as the configuration interface."] createform = createform(user,admincreatenotice,acusers) if acusers.include?("admin") participantcreatenotice = usercreatenotice || "" - user = ["participant","vote", + user = ["participant", "The user ‘participant’ has only access to the vote interface."] createform += createform(user,participantcreatenotice,acusers) end -- cgit v1.2.3