mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-13 09:20:38 -07:00
working on authentication
This commit is contained in:
parent
f3392f685d
commit
a018c42e0f
17 changed files with 154 additions and 80 deletions
|
|
@ -1,11 +1,8 @@
|
|||
class SchoolsController < ApplicationController
|
||||
before_action :authenticate_user!, except: [:show]
|
||||
before_action :set_school, only: [:admin, :show, :edit, :update, :destroy]
|
||||
before_action :verify_admin, except: [:show, :create, :new]
|
||||
|
||||
# GET /schools
|
||||
# GET /schools.json
|
||||
def index
|
||||
@schools = School.all
|
||||
end
|
||||
|
||||
# GET /schools/1
|
||||
# GET /schools/1.json
|
||||
|
|
@ -13,6 +10,9 @@ class SchoolsController < ApplicationController
|
|||
@school_categories = @school.school_categories.for_parent_category(@school, nil).sort
|
||||
end
|
||||
|
||||
def admin
|
||||
end
|
||||
|
||||
# GET /schools/new
|
||||
def new
|
||||
@school = School.new
|
||||
|
|
@ -72,4 +72,11 @@ class SchoolsController < ApplicationController
|
|||
def school_params
|
||||
params.require(:school).permit(:name, :district_id)
|
||||
end
|
||||
|
||||
def verify_admin
|
||||
return true if current_user.admin?(@school)
|
||||
|
||||
redirect_to root_path, notice: 'You must be logged in as an admin of that school to access that page.'
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue