Sha256: 23a584eb73f80a387ecd0c2a921744131c2fe2328791f862cd3295fded23cdd8
Contents?: true
Size: 842 Bytes
Versions: 1
Compression:
Stored size: 842 Bytes
Contents
module EducodeSales class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_action :authenticate_request def render_success render json: { success: true } end def render_failure(msg) render json: { success: false, msg: msg.is_a?(String) ? msg : msg.errors.full_messages.join(",") }, status: 403 end def current_user @current_admin = Staff.first @current_admin ||= Staff.find_by_id(session[:admin_id]) end def authenticate_request unless current_user redirect_to login_path end end def authenticate_admin unless current_user&.is_admin redirect_to no_permission_path end end rescue_from CanCan::AccessDenied do |exception| redirect_to no_permission_path end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
educode_sales-0.1.0 | app/controllers/educode_sales/application_controller.rb |