fixed input field to password type

This commit is contained in:
davidkartuzinski 2019-04-27 12:09:07 +02:00
parent 541b00041a
commit cbbce676ce

View File

@ -1,4 +1,4 @@
'use strict'; "use strict";
/** /**
* Module dependencies * Module dependencies
@ -7,61 +7,64 @@
// Public node modules. // Public node modules.
/* eslint-disable import/no-unresolved */ /* eslint-disable import/no-unresolved */
/* eslint-disable prefer-template */ /* eslint-disable prefer-template */
const cloudinary = require('cloudinary').v2; const cloudinary = require("cloudinary").v2;
const intoStream = require('into-stream'); const intoStream = require("into-stream");
module.exports = { module.exports = {
provider: 'cloudinary', provider: "cloudinary",
name: 'Cloudinary', name: "Cloudinary",
auth: { auth: {
cloud_name: { cloud_name: {
label: 'Cloud name', label: "Cloud name",
type: 'text' type: "text",
}, },
api_key: { api_key: {
label: 'API Key', label: "API Key",
type: 'text' type: "text",
}, },
api_secret: { api_secret: {
label: 'API Secret', label: "API Secret",
type: 'text' type: "password",
} },
}, },
init: (config) => { init: config => {
cloudinary.config({ cloudinary.config({
cloud_name: config.cloud_name, cloud_name: config.cloud_name,
api_key: config.api_key, api_key: config.api_key,
api_secret: config.api_secret api_secret: config.api_secret,
}); });
return { return {
upload (file) { upload(file) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const upload_stream = cloudinary.uploader.upload_stream({ resource_type: "auto" }, (err, image) => { const upload_stream = cloudinary.uploader.upload_stream(
if (err) { { resource_type: "auto" },
return reject(err); (err, image) => {
} if (err) {
file.public_id = image.public_id; return reject(err);
file.url = image.secure_url; }
resolve(); file.public_id = image.public_id;
}); file.url = image.secure_url;
resolve();
},
);
intoStream(file.buffer).pipe(upload_stream); intoStream(file.buffer).pipe(upload_stream);
}); });
}, },
async delete (file) { async delete(file) {
try { try {
const response = await cloudinary.uploader.destroy(file.public_id, { const response = await cloudinary.uploader.destroy(file.public_id, {
invalidate: true invalidate: true,
}); });
if (response.result !== 'ok') { if (response.result !== "ok") {
throw { throw {
error: new Error(response.result) error: new Error(response.result),
}; };
} }
} catch (error) { } catch (error) {
throw error.error; throw error.error;
} }
} },
}; };
} },
}; };