Skip to content

Commit

Permalink
remove validate Sass
Browse files Browse the repository at this point in the history
  • Loading branch information
bavuong0810 committed Jan 30, 2024
1 parent 03d8582 commit 2dbddfd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 58 deletions.
24 changes: 1 addition & 23 deletions admin/src/pages/Tabs/Configurations.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,6 @@ const Configurations = (props) => {
})
}

const validateSass = async (sassKey, token) => {
let headers = new Headers();
headers.append("Content-Type", "application/json");
headers.append("X-Filerobot-Key", sassKey);

const requestOptions = {
method: 'GET',
headers: headers,
redirect: 'follow'
};
const response = await fetch(`${filerobotApiDomain}/${token}/v4/files/`, requestOptions);
return response.json();
}

const getNewSassKey = async (config) => {
let sassReqHeaders = new Headers();
sassReqHeaders.append("Content-Type", "application/json");
Expand All @@ -89,15 +75,7 @@ const Configurations = (props) => {

const getSass = async (config) => {
let sass;
if (typeof (Storage) !== "undefined" && sessionStorage.getItem("sassKey")) {
sass = sessionStorage.getItem("sassKey");
const sassValidation = await validateSass(sass, config.token);
if (sassValidation.code === 'KEY_EXPIRED' || sassValidation.code === 'UNAUTHORIZED') {
sass = await getNewSassKey(config);
}
} else {
sass = await getNewSassKey(config);
}
sass = await getNewSassKey(config);
return sass;
}

Expand Down
40 changes: 5 additions & 35 deletions server/services/filerobot-by-scaleflex.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,7 @@ module.exports = ({strapi}) => ({

return media.length;
},
async validateSass(sassKey, token) {
const headers = new fetch.Headers();
headers.append("Content-Type", "application/json");
headers.append("X-Filerobot-Key", sassKey);

const requestOptions = {
method: 'GET',
headers: headers,
redirect: 'follow'
};

const response = await fetch(`${filerobotApiDomain}/${token}/v4/files/`, requestOptions);

return response.json();
},
async getNewSassKey(config) {
const sassReqHeaders = new fetch.Headers();
sassReqHeaders.append("Content-Type", "application/json");
Expand Down Expand Up @@ -245,29 +231,13 @@ module.exports = ({strapi}) => ({
async getSass(config) {
let sass = '';

if (typeof (Storage) !== "undefined" && sessionStorage.getItem("sassKey")) {
sass = sessionStorage.getItem("sassKey");

const sassValidation = await this.validateSass(sass, config.token);

if (sassValidation.code === 'KEY_EXPIRED' || sassValidation.code === 'UNAUTHORIZED') {
sass = await this.getNewSassKey(config);
sass = await this.getNewSassKey(config);

if (sass === false) {
return false;
}
}

return sass;
} else {
sass = await this.getNewSassKey(config);

if (sass === false) {
return false;
}

return sass;
if (sass === false) {
return false;
}

return sass;
},
removeQueryParam(link, paramName) {
const url = new URL(link);
Expand Down

0 comments on commit 2dbddfd

Please sign in to comment.