mirror of
https://github.com/iritmaximus/brewery.git
synced 2026-10-12 19:13:49 +03:00
upto 2.16
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user