mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
19 lines
370 B
Ruby
19 lines
370 B
Ruby
|
|
# frozen_string_literal: true
|
||
|
|
|
||
|
|
class ApiController < ApplicationController
|
||
|
|
skip_before_action :verify_authenticity_token
|
||
|
|
before_action :authenticate_api_key
|
||
|
|
|
||
|
|
private
|
||
|
|
|
||
|
|
def authenticate_api_key
|
||
|
|
return head :unauthorized unless current_api_user
|
||
|
|
|
||
|
|
true
|
||
|
|
end
|
||
|
|
|
||
|
|
def current_api_user
|
||
|
|
@current_api_user ||= User.find_by(api_key: params[:api_key])
|
||
|
|
end
|
||
|
|
end
|