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 @@ +

Admin Panel

+

+ 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 @@

LDAP users

diff --git a/app/views/shared/status_forbidden.html.erb b/app/views/shared/status_forbidden.html.erb new file mode 100644 index 0000000..a00cb2d --- /dev/null +++ b/app/views/shared/status_forbidden.html.erb @@ -0,0 +1,2 @@ +

Access forbidden

+

Not with those shoes, buddy.

diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index 44806c8..d3c0c52 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -3,8 +3,8 @@ en: devise: confirmations: - confirmed: "Your email address has been successfully confirmed." - send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes." + confirmed: "Your email address has been confirmed. You can now log in below." + send_instructions: "You will receive an email with instructions for how to confirm your email address in a moment." send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes." failure: already_authenticated: "You are already signed in." diff --git a/config/routes.rb b/config/routes.rb index 2985ea7..72a33b2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,7 +7,10 @@ Rails.application.routes.draw do get 'welcome', to: 'welcome#index' get 'check_your_email', to: 'welcome#check_your_email' - get 'ldap_users', to: 'ldap_users#index' + namespace :admin do + root to: 'dashboard#index' + get 'ldap_users', to: 'ldap_users#index' + end # Letter Opener (open "sent" emails in dev and staging) if Rails.env.match(/staging|development/) diff --git a/spec/views/ldap_users/index.html.erb_spec.rb b/spec/views/admin/dashboard/index.html.erb_spec.rb similarity index 59% rename from spec/views/ldap_users/index.html.erb_spec.rb rename to spec/views/admin/dashboard/index.html.erb_spec.rb index 2f3ad32..d9dbe04 100644 --- a/spec/views/ldap_users/index.html.erb_spec.rb +++ b/spec/views/admin/dashboard/index.html.erb_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -RSpec.describe "ldap_users/index.html.erb", type: :view do +RSpec.describe "dashboard/index.html.erb", type: :view do pending "add some examples to (or delete) #{__FILE__}" end