mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-26 20:54:21 +01:00
refactored ApplicationController + rubymine stub for devise
This commit is contained in:
parent
f6e236aeb5
commit
7ca72f53f2
@ -1,3 +1,6 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Main controller for the backend application. All controllers inherits from it
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
include Pundit
|
include Pundit
|
||||||
# Prevent CSRF attacks by raising an exception.
|
# Prevent CSRF attacks by raising an exception.
|
||||||
@ -14,10 +17,10 @@ class ApplicationController < ActionController::Base
|
|||||||
# Returning 403 Forbidden if permission is denied
|
# Returning 403 Forbidden if permission is denied
|
||||||
rescue_from Pundit::NotAuthorizedError, with: :permission_denied
|
rescue_from Pundit::NotAuthorizedError, with: :permission_denied
|
||||||
|
|
||||||
def index
|
def index; end
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def set_csrf_cookie
|
def set_csrf_cookie
|
||||||
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
|
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
|
||||||
end
|
end
|
||||||
@ -28,17 +31,24 @@ class ApplicationController < ActionController::Base
|
|||||||
|
|
||||||
def configure_permitted_parameters
|
def configure_permitted_parameters
|
||||||
devise_parameter_sanitizer.for(:sign_up) <<
|
devise_parameter_sanitizer.for(:sign_up) <<
|
||||||
{profile_attributes: [:phone, :last_name, :first_name,
|
{ profile_attributes: [:phone, :last_name, :first_name, :gender, :birthday, :interest, :software_mastered,
|
||||||
:gender, :birthday, :interest, :software_mastered,
|
|
||||||
organization_attributes: [:name, address_attributes: [:address]]] }
|
organization_attributes: [:name, address_attributes: [:address]]] }
|
||||||
devise_parameter_sanitizer.for(:sign_up).concat [:username, :is_allow_contact, :is_allow_newsletter, :cgu, :group_id]
|
|
||||||
|
devise_parameter_sanitizer.for(:sign_up).concat %i[username is_allow_contact is_allow_newsletter cgu group_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_url_options
|
def default_url_options
|
||||||
{ :host => Rails.application.secrets.default_host, protocol: Rails.application.secrets.default_protocol }
|
{ host: Rails.application.secrets.default_host, protocol: Rails.application.secrets.default_protocol }
|
||||||
end
|
end
|
||||||
|
|
||||||
def permission_denied
|
def permission_denied
|
||||||
head 403
|
head 403
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [User]
|
||||||
|
# This is a placeholder for Devise's current_user.
|
||||||
|
# As Devise generate the method at runtime, IDEs autocomplete features will complain about 'method not found'
|
||||||
|
def current_user
|
||||||
|
super
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user