1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2025-11-30 21:32:30 +00:00

style(rubocop): fix all safe auto correctable offenses

هذا الالتزام موجود في:
Charlie Smurthwaite
2023-03-16 15:50:53 +00:00
الأصل 02c93a4850
التزام fd289c46fd
204 ملفات معدلة مع 2611 إضافات و2486 حذوفات

عرض الملف

@@ -1,4 +1,4 @@
require 'authie/session'
require "authie/session"
class ApplicationController < ActionController::Base
@@ -7,37 +7,37 @@ class ApplicationController < ActionController::Base
before_action :login_required
before_action :set_timezone
rescue_from Authie::Session::InactiveSession, :with => :auth_session_error
rescue_from Authie::Session::ExpiredSession, :with => :auth_session_error
rescue_from Authie::Session::BrowserMismatch, :with => :auth_session_error
rescue_from Authie::Session::InactiveSession, with: :auth_session_error
rescue_from Authie::Session::ExpiredSession, with: :auth_session_error
rescue_from Authie::Session::BrowserMismatch, with: :auth_session_error
private
def login_required
unless logged_in?
redirect_to login_path(:return_to => request.fullpath)
end
return if logged_in?
redirect_to login_path(return_to: request.fullpath)
end
def admin_required
if logged_in?
unless current_user.admin?
render :plain => "Not permitted"
render plain: "Not permitted"
end
else
redirect_to login_path(:return_to => request.fullpath)
redirect_to login_path(return_to: request.fullpath)
end
end
def require_organization_owner
unless organization.owner == current_user
redirect_to organization_root_path(organization), :alert => "This page can only be accessed by the organization's owner (#{organization.owner.name})"
end
return if organization.owner == current_user
redirect_to organization_root_path(organization), alert: "This page can only be accessed by the organization's owner (#{organization.owner.name})"
end
def auth_session_error(exception)
Rails.logger.info "AuthSessionError: #{exception.class}: #{exception.message}"
redirect_to login_path(:return_to => request.fullpath)
redirect_to login_path(return_to: request.fullpath)
end
def page_title
@@ -46,7 +46,7 @@ class ApplicationController < ActionController::Base
helper_method :page_title
def redirect_to_with_return_to(url, *args)
if params[:return_to].blank? || !params[:return_to].starts_with?('/')
if params[:return_to].blank? || !params[:return_to].starts_with?("/")
redirect_to url_with_return_to(url), *args
else
redirect_to url_with_return_to(url), *args
@@ -54,7 +54,7 @@ class ApplicationController < ActionController::Base
end
def set_timezone
Time.zone = logged_in? ? current_user.time_zone : 'UTC'
Time.zone = logged_in? ? current_user.time_zone : "UTC"
end
def append_info_to_payload(payload)
@@ -64,7 +64,7 @@ class ApplicationController < ActionController::Base
end
def url_with_return_to(url)
if params[:return_to].blank? || !params[:return_to].starts_with?('/')
if params[:return_to].blank? || !params[:return_to].starts_with?("/")
url_for(url)
else
params[:return_to]
@@ -83,14 +83,14 @@ class ApplicationController < ActionController::Base
end
respond_to do |wants|
wants.html { redirect_to url }
wants.json { render :json => {:redirect_to => url} }
wants.json { render json: { redirect_to: url } }
end
end
def render_form_errors(action_name, object)
respond_to do |wants|
wants.html { render action_name }
wants.json { render :json => {:form_errors => object.errors.full_messages}, :status => 422 }
wants.json { render json: { form_errors: object.errors.full_messages }, status: :unprocessable_entity }
end
end
@@ -102,7 +102,7 @@ class ApplicationController < ActionController::Base
render options[:render_action]
end
end
wants.json { render :json => {:flash => {type => message}} }
wants.json { render json: { flash: { type => message } } }
end
end
@@ -111,7 +111,7 @@ class ApplicationController < ActionController::Base
auth_session.invalidate!
reset_session
end
Authie::Session.start(self, :user => user)
Authie::Session.start(self, user: user)
@current_user = user
end