Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!user) {
res.status(404).send('User not found.')
return
}
// Is requesting user logged in?
if (user.login_tokens.indexOf(req.loginToken) === -1) {
res.status(401).end()
return
}
// If requesting user is logged in, permission granted to receive cloudinary signature.
let signature
try {
signature = await cloudinary.utils.api_sign_request(query, config.cloudinary.api_secret)
} catch (error) {
logger.error(error)
res.status(500).send('Error generating signature.')
}
if (!signature) {
res.status(404).send('Signature could not be generated.')
}
const payload = {
signature: signature,
timestamp: query.timestamp,
api_key: config.cloudinary.api_key
}
res.status(200).json(payload)
if (!user) {
res.status(404).send('User not found.')
return
}
// Is requesting user logged in?
if (user.login_tokens.indexOf(req.loginToken) === -1) {
res.status(401).end()
return
}
// If requesting user is logged in, permission granted to receive cloudinary signature.
let signature
try {
signature = await cloudinary.utils.api_sign_request(query, config.cloudinary.api_secret)
} catch (error) {
logger.error(error)
res.status(500).send('Error generating signature.')
}
if (!signature) {
res.status(404).send('Signature could not be generated.')
}
const payload = {
signature: signature,
timestamp: query.timestamp,
api_key: config.cloudinary.api_key
}
res.status(200).json(payload)
const getPromise = (metadata, prop) => {
if (metadata[prop]) {
try {
return {
id: metadata[prop],
url: cloudinary.utils.url(metadata[prop], {
type: 'fetch',
transformation: props[prop],
}),
width: props[prop].width,
height: props[prop].height,
};
} catch (err) {}
}
};
var getSignedRequest = exports.getSignedRequest = function getSignedRequest(config) {
return transformSignature(config, cloudinary.utils.sign_request({
timestamp: Math.round(new Date().getTime() / 1000),
folder: APP ? APP + '/' : null
}, config));
};
export const getSignedRequest = config =>
transformSignature(
config,
cloudinary.utils.sign_request(
{
timestamp: Math.round(new Date().getTime() / 1000),
folder: APP ? `${APP}/` : null,
},
config,
),
);