upto 2.16

This commit is contained in:
Aaro Koivukangas
2023-08-08 15:20:25 +03:00
parent 837f739992
commit fc2fc93ab0
+9
View File
@@ -1,5 +1,6 @@
class BreweriesController < ApplicationController
before_action :set_brewery, only: %i[ show edit update destroy ]
before_action :authenticate, only: [:destroy]
# GET /breweries or /breweries.json
def index
@@ -67,4 +68,12 @@ class BreweriesController < ApplicationController
def brewery_params
params.require(:brewery).permit(:name, :year)
end
def authenticate
admin_accounts = {"martti" => "anaatti", "moi"=> "hei"}
authenticate_or_request_with_http_basic do |username, password|
raise "Wrong username or password" unless admin_accounts.key? username and admin_accounts[username] == password
return true
end
end
end