diff --git a/app/assets/stylesheets/fonts.scss b/app/assets/stylesheets/fonts.scss index 03396e2..52127fc 100644 --- a/app/assets/stylesheets/fonts.scss +++ b/app/assets/stylesheets/fonts.scss @@ -5,8 +5,19 @@ font-style: normal; } -h1 { - font-family: Raleway, sans-serif; +body { + font-family: "Open Sans", Helvetica, Arial, sans-serif; + font-weight: 400; +} + +h1, h2, h3 { + font-family: Raleway, inherit; font-weight: 300; +} + +h1 { text-transform: uppercase; } + +h2 { +} diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index dac2b9b..e60ec45 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -2,8 +2,6 @@ $content-width: 800px; $content-max-width: 100%; body { - font-family: "Open Sans", Helvetica, Arial, sans-serif; - font-weight: 400; } #wrapper { diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb new file mode 100644 index 0000000..883c829 --- /dev/null +++ b/app/controllers/admin/base_controller.rb @@ -0,0 +1,6 @@ +class Admin::BaseController < ApplicationController + + before_action :authenticate_user! + before_action :authorize_admin + +end diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb new file mode 100644 index 0000000..311d077 --- /dev/null +++ b/app/controllers/admin/dashboard_controller.rb @@ -0,0 +1,4 @@ +class Admin::DashboardController < Admin::BaseController + def index + end +end diff --git a/app/controllers/ldap_users_controller.rb b/app/controllers/admin/ldap_users_controller.rb similarity index 95% rename from app/controllers/ldap_users_controller.rb rename to app/controllers/admin/ldap_users_controller.rb index 4124b3e..9d5be6e 100644 --- a/app/controllers/ldap_users_controller.rb +++ b/app/controllers/admin/ldap_users_controller.rb @@ -1,4 +1,4 @@ -class LdapUsersController < ApplicationController +class Admin::LdapUsersController < Admin::BaseController def index attributes = %w{dn cn uid mail admin} filter = Net::LDAP::Filter.eq("uid", "*") diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 570fc77..dd4cf1c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,4 +8,15 @@ class ApplicationController < ActionController::Base redirect_to welcome_path and return end end + + def authorize_admin + http_status :forbidden unless current_user.is_admin? + end + + def http_status(status) + respond_to do |format| + format.html { render template: "shared/status_#{status.to_s}", status: status } + format.any { head status } + end + end end diff --git a/app/models/user.rb b/app/models/user.rb index 6ca9f77..53b5ca2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,4 +19,12 @@ class User < ApplicationRecord clear_reset_password_token if valid? save end + + def is_admin? + admin ||= if admin = Devise::LDAP::Adapter.get_ldap_param(self.cn, :admin) + !!admin.first + else + false + end + end end diff --git a/app/views/admin/dashboard/index.html.erb b/app/views/admin/dashboard/index.html.erb new file mode 100644 index 0000000..0019cc4 --- /dev/null +++ b/app/views/admin/dashboard/index.html.erb @@ -0,0 +1,4 @@ +
+ Ohai there, admin human. +
diff --git a/app/views/ldap_users/index.html.erb b/app/views/admin/ldap_users/index.html.erb similarity index 75% rename from app/views/ldap_users/index.html.erb rename to app/views/admin/ldap_users/index.html.erb index 452a877..705ed5b 100644 --- a/app/views/ldap_users/index.html.erb +++ b/app/views/admin/ldap_users/index.html.erb @@ -1,8 +1,8 @@