Add generation of the Canny SSO token

This commit is contained in:
Andreas Nedbal 2022-01-22 07:39:33 +01:00 committed by Andreas Nedbal
parent 4d4296de19
commit 7374aba6d3
5 changed files with 20 additions and 0 deletions

View File

@ -64,6 +64,8 @@ gem "redis"
gem "fake_email_validator" gem "fake_email_validator"
gem "jwt", "~> 2.3"
group :development do group :development do
gem "binding_of_caller" gem "binding_of_caller"
gem "byebug" gem "byebug"

View File

@ -291,6 +291,7 @@ GEM
jquery-ui-rails (6.0.1) jquery-ui-rails (6.0.1)
railties (>= 3.2.16) railties (>= 3.2.16)
json (2.6.1) json (2.6.1)
jwt (2.3.0)
kaminari (1.2.2) kaminari (1.2.2)
activesupport (>= 4.1.0) activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.2) kaminari-actionview (= 1.2.2)
@ -639,6 +640,7 @@ DEPENDENCIES
httparty httparty
i18n-js (= 3.6) i18n-js (= 3.6)
jbuilder (~> 2.10) jbuilder (~> 2.10)
jwt (~> 2.3)
letter_opener letter_opener
mini_magick mini_magick
omniauth omniauth

View File

@ -0,0 +1,14 @@
module FeedbackHelper
def canny_token
return if current_user.nil?
userData = {
avatarURL: current_user.profile_picture.url(:large),
name: current_user.screen_name,
id: current_user.id,
email: current_user.email
}
JWT.encode(userData, APP_CONFIG.dig("canny", "sso"))
end
end

View File

@ -6,5 +6,6 @@
%script %script
Canny('render', { Canny('render', {
boardToken: '#{APP_CONFIG['canny']['bug_board']}', boardToken: '#{APP_CONFIG['canny']['bug_board']}',
ssoToken: '#{canny_token}',
basePath: '/feedback/bugs' basePath: '/feedback/bugs'
}); });

View File

@ -6,5 +6,6 @@
%script %script
Canny('render', { Canny('render', {
boardToken: '#{APP_CONFIG['canny']['feature_board']}', boardToken: '#{APP_CONFIG['canny']['feature_board']}',
ssoToken: '#{canny_token}',
basePath: '/feedback/feature-requests' basePath: '/feedback/feature-requests'
}); });