FIX: allows authentication data to be present in bootstrap (#13885)

This commit is contained in:
Joffrey JAFFEUX 2021-07-29 15:01:11 +02:00 committed by GitHub
parent 2b5625bbf0
commit 74f0631acd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View File

@ -45,6 +45,14 @@ function head(buffer, bootstrap) {
buffer.push(`<meta name="theme-color" content="${bootstrap.theme_color}">`);
}
if (bootstrap.authentication_data) {
buffer.push(
`<meta id="data-authentication" data-authentication-data="${encode(
bootstrap.authentication_data
)}">`
);
}
let setupData = "";
Object.keys(bootstrap.setup_data).forEach((sd) => {
let val = bootstrap.setup_data[sd];

View File

@ -67,7 +67,8 @@ class BootstrapController < ApplicationController
theme_html: create_theme_html,
html_classes: html_classes,
html_lang: html_lang,
login_path: main_app.login_path
login_path: main_app.login_path,
authentication_data: authentication_data
}
bootstrap[:extra_locales] = extra_locales if extra_locales.present?
bootstrap[:csrf_token] = form_authenticity_token if current_user

View File

@ -81,4 +81,16 @@ describe BootstrapController do
expect(response.status).to eq(200)
expect(response.parsed_body).to be_present
end
context "authentication data is present" do
it "returns authentication data" do
cookie_data = 'someauthenticationdata'
cookies['authentication_data'] = cookie_data
get "/bootstrap.json"
bootstrap = response.parsed_body['bootstrap']
expect(bootstrap['authentication_data']).to eq(cookie_data)
end
end
end