* Removes FeatureFlag.enabled?(:creator_onboarding) from codebase * Removes FeatureFlag.enabled?(:creator_onboarding) from specs * Further cleanup, removal, and spec fixes * Fixes the user_request_confirmation_spec.rb * Reverts change to confirmation email button * Revert revert after looking at designs again :( * Removes redundant logo_png field from config + fixes test * Rewords an expectation in user_uses_the_editor_spec.rb * Revert removal of logo_png from Config images * Removes CSS class from user_uses_the_editor_spec.rb * Removes test from user_uses_the_editor_sepc.rb * Removes unnecessary else from _logo.html.erb * Adds back removed system spec * Removes SVG-related code from _logo.html.erb * Removes AsyncInfoController#use_creator_onboarding * Fixes spec failues due to removed code * Removes svg-related code (that I thought I removed already :/ ) * Re-removes FeatureFlag and logo_svg from _images.html.erb * Remove newest instances of FeatureFlag(:creator_onboarding) * remove instances where we use the creator_onboarding field from the base_data * fix: redirect to the correct path in the reguistrations controller based on whether the user is a creator or not Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
67 lines
2 KiB
JavaScript
67 lines
2 KiB
JavaScript
/* global checkUserLoggedIn */
|
|
|
|
function removeExistingCSRF() {
|
|
var csrfTokenMeta = document.querySelector("meta[name='csrf-token']");
|
|
var csrfParamMeta = document.querySelector("meta[name='csrf-param']");
|
|
if (csrfTokenMeta && csrfParamMeta) {
|
|
csrfTokenMeta.parentNode.removeChild(csrfTokenMeta);
|
|
csrfParamMeta.parentNode.removeChild(csrfParamMeta);
|
|
}
|
|
}
|
|
|
|
function fetchBaseData() {
|
|
var xmlhttp;
|
|
if (window.XMLHttpRequest) {
|
|
xmlhttp = new XMLHttpRequest();
|
|
} else {
|
|
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
|
|
}
|
|
xmlhttp.onreadystatechange = () => {
|
|
if (xmlhttp.readyState === XMLHttpRequest.DONE) {
|
|
// Assigning CSRF
|
|
var json = JSON.parse(xmlhttp.responseText);
|
|
if (json.token) {
|
|
removeExistingCSRF();
|
|
}
|
|
var newCsrfParamMeta = document.createElement('meta');
|
|
newCsrfParamMeta.name = 'csrf-param';
|
|
newCsrfParamMeta.content = json.param;
|
|
document.head.appendChild(newCsrfParamMeta);
|
|
var newCsrfTokenMeta = document.createElement('meta');
|
|
newCsrfTokenMeta.name = 'csrf-token';
|
|
newCsrfTokenMeta.content = json.token;
|
|
document.head.appendChild(newCsrfTokenMeta);
|
|
document.body.dataset.loaded = 'true';
|
|
|
|
// Assigning Broadcast
|
|
if (json.broadcast) {
|
|
document.body.dataset.broadcast = json.broadcast;
|
|
}
|
|
|
|
// Assigning User
|
|
if (checkUserLoggedIn()) {
|
|
document.body.dataset.user = json.user;
|
|
document.body.dataset.creator = json.creator;
|
|
browserStoreCache('set', json.user);
|
|
|
|
setTimeout(() => {
|
|
if (typeof ga === 'function') {
|
|
ga('set', 'userId', JSON.parse(json.user).id);
|
|
}
|
|
}, 400);
|
|
} else {
|
|
// Ensure user data is not exposed if no one is logged in
|
|
delete document.body.dataset.user;
|
|
delete document.body.dataset.creator;
|
|
browserStoreCache('remove');
|
|
}
|
|
}
|
|
};
|
|
|
|
xmlhttp.open('GET', '/async_info/base_data', true);
|
|
xmlhttp.send();
|
|
}
|
|
|
|
function initializeBodyData() {
|
|
fetchBaseData();
|
|
}
|