mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
25 lines
511 B
Ruby
25 lines
511 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ApplicationController < ActionController::Base
|
|
include Pundit::Authorization
|
|
|
|
before_action :unread_notifications
|
|
|
|
protected
|
|
|
|
def unread_notifications
|
|
return [] unless current_user
|
|
|
|
@unread_notifications ||= Notification.where(user: current_user).unread
|
|
end
|
|
|
|
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
|