Skip to content

Commit

Permalink
fixing i18n issue
Browse files Browse the repository at this point in the history
Signed-off-by: progress <shravani.roy@progress.com>
  • Loading branch information
RoyShravani committed May 18, 2023
1 parent 79b04e1 commit 80a43d5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
9 changes: 6 additions & 3 deletions src/oc-id/app/controllers/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,15 @@ def regen_key

private

def goto_forbidden(message, *args)
def goto_forbidden(message, **args)
if signed_in?
flash.now[:alert] = I18n.t(message, *args)
# The I18n.t method uses keyword arguments.
# There is a breaking change in ruby that produces warning with ruby 2.7 and won't work as expected with ruby 3.0
# The "hash" parameter must be passed as keyword argument.
flash.now[:alert] = I18n.t(message, **args)
render 'show', status: :forbidden
else
redirect_to signin_path, notice: I18n.t(message, *args)
redirect_to signin_path, notice: I18n.t(message, **args)
end
end

Expand Down
8 changes: 4 additions & 4 deletions src/oc-id/lib/chef/web/core/asset_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def chef_logo(element = :div, opts = {})
if opts[:data][:'tag-line']
opts[:svg].css('#chef-logo-tag-line text').first.content = opts[:data][:'tag-line']
end

attrs = opts[:attributes].map { |k, v| %(#{k}="#{v}") }
attrs << opts[:data].map { |k, v| %(data-#{k}="#{v}") }
attrs = opts[:attributes].map { |k, v| %Q(#{k}="#{v}") }
attrs << opts[:data].map { |k, v| %Q(data-#{k}="#{v}") }
opts[:attributes] = attrs.join(' ')

Chef::Web::Core::Component.new(opts.merge!(element:, type: 'logo')).render
Chef::Web::Core::Component.new(opts.merge!(:element => element, :type => 'logo')).render
end
end
end
Expand Down
14 changes: 7 additions & 7 deletions src/oc-id/lib/health_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
class HealthCheck
include ChefResource

OK = 'ok'
NOT_OK = 'not ok'
REACHABLE = 'reachable'
TIMEOUT = 'timeout'
UNREACHABLE = 'unreachable'
ERRORING = 'erroring'
AUTHERROR = 'authentication error'
OK = 'ok'.freeze
NOT_OK = 'not ok'.freeze
REACHABLE = 'reachable'.freeze
TIMEOUT = 'timeout'.freeze
UNREACHABLE = 'unreachable'.freeze
ERRORING = 'erroring'.freeze
AUTHERROR = 'authentication error'.freeze

attr_reader :status, :erchef, :postgres

Expand Down
20 changes: 10 additions & 10 deletions src/oc-id/lib/zendesk_sso_url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'securerandom'
require 'uri'

class ZendeskSsoUrl
class ZendeskSSOURL
attr_reader :user, :return_to, :settings

def initialize(user, return_to, settings)
Expand All @@ -16,9 +16,9 @@ def initialize(user, return_to, settings)

def to_s
URI::HTTPS.build(
host:,
path:,
query: query_hash.to_query
host: host,
path: path,
query: query_hash.to_query,
).to_s
end

Expand All @@ -38,16 +38,16 @@ def payload
jti = "#{iat}/#{SecureRandom.hex(18)}"

JWT.encode({
iat:,
jti:,
name: [user.first_name, user.last_name].compact.join(' '),
email: user.email
}, settings.shared_secret)
iat: iat,
jti: jti,
name: [user.first_name, user.last_name].compact.join(' '),
email: user.email,
}, settings.shared_secret)
end

def query_hash
q = { jwt: payload }
q[:return_to] = CGI.escape(return_to) if return_to.present?
q
end
end
end

0 comments on commit 80a43d5

Please sign in to comment.