Class: EducodeSales::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/educode_sales/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#authenticate_adminObject



24
25
26
27
28
# File 'app/controllers/educode_sales/application_controller.rb', line 24

def authenticate_admin
  unless current_user&.is_admin
    redirect_to no_permission_path
  end
end

#authenticate_requestObject



18
19
20
21
22
# File 'app/controllers/educode_sales/application_controller.rb', line 18

def authenticate_request
  unless current_user
    redirect_to 
  end
end

#current_userObject



14
15
16
# File 'app/controllers/educode_sales/application_controller.rb', line 14

def current_user
  @current_admin ||= Staff.find_by_id(session[:admin_id])
end

#render_failure(msg) ⇒ Object



10
11
12
# File 'app/controllers/educode_sales/application_controller.rb', line 10

def render_failure(msg)
  render json: { success: false, msg: msg.is_a?(String) ? msg : msg.errors.full_messages.join(",") }, status: 403
end

#render_successObject



6
7
8
# File 'app/controllers/educode_sales/application_controller.rb', line 6

def render_success
  render json: { success: true }
end