add authentication by district

pull/1/head
rebuilt 3 years ago
parent 77bf65f436
commit 7d387dbe0e

@ -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…
Cancel
Save