Added Reports Server Authorization to client side. IO-390
This commit is contained in:
@@ -19,8 +19,7 @@ const wsLink = new WebSocketLink({
|
|||||||
lazy: true,
|
lazy: true,
|
||||||
reconnect: true,
|
reconnect: true,
|
||||||
connectionParams: async () => {
|
connectionParams: async () => {
|
||||||
const token =
|
const token = auth.currentUser && (await auth.currentUser.getIdToken());
|
||||||
auth.currentUser && (await auth.currentUser.getIdToken(true));
|
|
||||||
if (token) {
|
if (token) {
|
||||||
return {
|
return {
|
||||||
headers: {
|
headers: {
|
||||||
@@ -35,7 +34,7 @@ const wsLink = new WebSocketLink({
|
|||||||
const subscriptionMiddleware = {
|
const subscriptionMiddleware = {
|
||||||
applyMiddleware: async (options, next) => {
|
applyMiddleware: async (options, next) => {
|
||||||
options.authToken =
|
options.authToken =
|
||||||
auth.currentUser && (await auth.currentUser.getIdToken(true));
|
auth.currentUser && (await auth.currentUser.getIdToken());
|
||||||
next();
|
next();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import gql from "graphql-tag";
|
import gql from "graphql-tag";
|
||||||
import jsreport from "jsreport-browser-client-dist";
|
import jsreport from "jsreport-browser-client-dist";
|
||||||
import client from "../utils/GraphQLClient";
|
import client from "../utils/GraphQLClient";
|
||||||
import cleanAxios from "./CleanAxios";
|
import axios from "axios";
|
||||||
|
import { auth } from "../firebase/firebase.utils";
|
||||||
const server = "https://reports.bodyshop.app";
|
const server = process.env.REACT_APP_REPORTS_SERVER_URL;
|
||||||
jsreport.serverUrl = server;
|
jsreport.serverUrl = server;
|
||||||
jsreport.headers["Authorization"] = "Basic " + btoa("admin:admin");
|
|
||||||
|
|
||||||
export default async function RenderTemplate(
|
export default async function RenderTemplate(
|
||||||
templateObject,
|
templateObject,
|
||||||
@@ -21,9 +20,12 @@ export default async function RenderTemplate(
|
|||||||
// },
|
// },
|
||||||
|
|
||||||
//Query assets that match the template name. Must be in format <<templateName>>.query
|
//Query assets that match the template name. Must be in format <<templateName>>.query
|
||||||
const jsReportQueries = await cleanAxios.get(
|
|
||||||
`${server}/odata/assets?$filter=name eq '${templateObject.name}.query'`,
|
jsreport.headers["Authorization"] =
|
||||||
{ headers: { Authorization: "Basic " + btoa("admin:admin") } }
|
"Bearer " + (await auth.currentUser.getIdToken());
|
||||||
|
|
||||||
|
const jsReportQueries = await axios.get(
|
||||||
|
`${server}/odata/assets?$filter=name eq '${templateObject.name}.query'`
|
||||||
);
|
);
|
||||||
|
|
||||||
let templateQueryToExecute,
|
let templateQueryToExecute,
|
||||||
|
|||||||
Reference in New Issue
Block a user