[ Login and logout ]
This commit is contained in:
parent
551062f92e
commit
fb229b3950
4 changed files with 159 additions and 23 deletions
26
tonton.rb
26
tonton.rb
|
|
@ -98,29 +98,11 @@ class TonTon::App < Precious::App
|
|||
end
|
||||
|
||||
before do
|
||||
public_patterns = [
|
||||
'/',
|
||||
'/*',
|
||||
'/login',
|
||||
'/logout',
|
||||
'/unauthenticated',
|
||||
'/gollum/*',
|
||||
'/gollum/history/**',
|
||||
'/gollum/latest_changes',
|
||||
'/gollum/commit/**'
|
||||
]
|
||||
|
||||
request_path = Pathname.new(request.path_info)
|
||||
|
||||
looks_public = false
|
||||
|
||||
for pattern in public_patterns
|
||||
if request_path.fnmatch(pattern, File::FNM_PATHNAME)
|
||||
looks_public = true
|
||||
end
|
||||
if not env['warden'].authenticated?
|
||||
@allow_editing = false
|
||||
else
|
||||
@allow_editing = true
|
||||
end
|
||||
|
||||
if not looks_public then check_authentication end
|
||||
end
|
||||
|
||||
post '/unauthenticated' do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue