aboutsummaryrefslogtreecommitdiff
path: root/interfaces/http
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-03-13 22:05:55 +0100
committerJohn Ankarström <john@ankarstrom.se>2021-03-13 22:05:55 +0100
commit69c0dff574cbe13bd3b9c23bde10a685dce16b2a (patch)
tree92a264e8e1b53afe4832572b79093da599722dea /interfaces/http
parentedd1b21f926f0bcec0033b4b481fe12f54029224 (diff)
downloadcomb-69c0dff574cbe13bd3b9c23bde10a685dce16b2a.tar.gz
Add sessionsHEADmaster
Diffstat (limited to 'interfaces/http')
-rw-r--r--interfaces/http/admin/admin.rb22
1 files changed, 20 insertions, 2 deletions
diff --git a/interfaces/http/admin/admin.rb b/interfaces/http/admin/admin.rb
index 347a051..40cbe07 100644
--- a/interfaces/http/admin/admin.rb
+++ b/interfaces/http/admin/admin.rb
@@ -1,13 +1,31 @@
class AdminInterface < Sinatra::Base
enable :sessions
+ helpers do
+ def logged_in?
+ @session != nil
+ end
+ end
+
+ before do
+ @session = Session.where code: session[:code]
+ end
+
before ['/admin', '/admin/*'] do
- redirect '/login', 303 if not false
+ redirect '/login', 303 if not logged_in?
end
-
+
get '/login' do
end
+ post '/login' do
+ @session = Session.start(params)
+ if @session then
+ else
+ redirect '/login', 401
+ end
+ end
+
get '/admin' do
@title = $config.title
@posts = Post.all