Fixed web password protection (was broken by earlier refactoring), also adcded some user-friendlines to it
This commit is contained in:
parent
c73db9ff5d
commit
ae7ac63a9d
|
@ -31,7 +31,7 @@ class ApplicationController < ActionController::Base
|
||||||
if in_a_web? and
|
if in_a_web? and
|
||||||
not authorized? and
|
not authorized? and
|
||||||
not %w( login authenticate published ).include?(@action_name)
|
not %w( login authenticate published ).include?(@action_name)
|
||||||
redirect_to :action => 'login'
|
redirect_to :action => 'login', :web => @web_name
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -72,6 +72,15 @@ class ApplicationController < ActionController::Base
|
||||||
not @web_name.nil?
|
not @web_name.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def password_check(password)
|
||||||
|
if password == @web.password
|
||||||
|
cookies['web_address'] = password
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def password_error(password)
|
def password_error(password)
|
||||||
if password.nil? or password.empty?
|
if password.nil? or password.empty?
|
||||||
'Please enter the password.'
|
'Please enter the password.'
|
||||||
|
|
|
@ -25,6 +25,7 @@ class WikiController < ApplicationController
|
||||||
if password_check(@params['password'])
|
if password_check(@params['password'])
|
||||||
redirect_show('HomePage')
|
redirect_show('HomePage')
|
||||||
else
|
else
|
||||||
|
flash[:info] = password_error(@params['password'])
|
||||||
redirect_to :action => 'login', :web => @web_name
|
redirect_to :action => 'login', :web => @web_name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -308,15 +309,6 @@ class WikiController < ApplicationController
|
||||||
[ limit, start_date, end_date ]
|
[ limit, start_date, end_date ]
|
||||||
end
|
end
|
||||||
|
|
||||||
def password_check(password)
|
|
||||||
if password == @web.password
|
|
||||||
cookies['web_address'] = password
|
|
||||||
true
|
|
||||||
else
|
|
||||||
false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def remote_ip
|
def remote_ip
|
||||||
ip = @request.remote_ip
|
ip = @request.remote_ip
|
||||||
logger.info(ip)
|
logger.info(ip)
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
<% @title = "#{@web_name} Login" %><% @hide_navigation = true %>
|
<% @title = "#{@web_name} Login" %><% @hide_navigation = true %>
|
||||||
|
|
||||||
<form action="authenticate" method="post">
|
|
||||||
<p>
|
<%= form_tag({ :controller => 'wiki', :action => 'authenticate', :web => @web.address},
|
||||||
|
{'id' => 'loginForm', 'method' => 'post'})
|
||||||
|
%>
|
||||||
|
<p>
|
||||||
<b>Password</b><br />
|
<b>Password</b><br />
|
||||||
<input type="password" name="password" />
|
<input type="password" name="password" />
|
||||||
</p>
|
</p>
|
||||||
</form>
|
<%= end_form_tag %>
|
||||||
|
|
Loading…
Reference in a new issue