aboutsummaryrefslogtreecommitdiff
path: root/interfaces/http/admin
diff options
context:
space:
mode:
Diffstat (limited to 'interfaces/http/admin')
-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