mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-12 19:48:36 +00:00
* Improves ruby code in app/models/app_user.rb based on suggestions from Rubocop * Rubocop fixes for more models * Rubocop fixes for controllers
20 lines
554 B
Ruby
20 lines
554 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ApplicationController < ActionController::API
|
|
include Pundit
|
|
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
|
|
|
|
before_action :authenticate_request
|
|
attr_reader :current_user
|
|
|
|
private
|
|
|
|
def authenticate_request
|
|
@current_user = AuthorizeApiRequest.call(request.headers).result
|
|
render json: { error: "Not Authorized" }, status: :unauthorized unless @current_user
|
|
end
|
|
|
|
def user_not_authorized
|
|
render json: { error: "Access denied" }, status: :forbidden
|
|
end
|
|
end
|