mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
add authentication by district
This commit is contained in:
parent
77bf65f436
commit
7d387dbe0e
1 changed files with 12 additions and 0 deletions
|
|
@ -4,10 +4,16 @@ class SqmApplicationController < ApplicationController
|
|||
protect_from_forgery with: :exception, prepend: true
|
||||
before_action :set_schools_and_districts
|
||||
before_action :response_rate_timestamp
|
||||
before_action :authenticate_district
|
||||
helper HeaderHelper
|
||||
|
||||
private
|
||||
|
||||
def authenticate_district
|
||||
name = @district.name.split(" ").first.downcase
|
||||
authenticate(name, "#{name}!")
|
||||
end
|
||||
|
||||
def set_schools_and_districts
|
||||
@district = District.find_by_slug district_slug
|
||||
@districts = District.all.order(:name)
|
||||
|
|
@ -24,4 +30,10 @@ class SqmApplicationController < ApplicationController
|
|||
def school_slug
|
||||
params[:school_id]
|
||||
end
|
||||
|
||||
def authenticate(username, password)
|
||||
authenticate_or_request_with_http_basic do |u, p|
|
||||
u == username && p == password
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue