|
|
@ -9,15 +9,16 @@ module.exports = Self => {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
Self.getOptions = async() => {
|
|
|
|
Self.getOptions = async() => {
|
|
|
|
const {url, username, password} = await Self.app.models.DocuwareConfig.findOne();
|
|
|
|
const {url, username, password} = await Self.app.models.DocuwareConfig.findOne();
|
|
|
|
const {IdentityServiceUrl} = await axios.get(`${url}/Home/IdentityServiceInfo`);
|
|
|
|
const {data: {IdentityServiceUrl}} = await axios.get(`${url}/Home/IdentityServiceInfo`);
|
|
|
|
const {token_endpoint} = await axios.get(`${IdentityServiceUrl}/.well-known/openid-configuration`);
|
|
|
|
const {data: {token_endpoint}} = await axios.get(`${IdentityServiceUrl}/.well-known/openid-configuration`);
|
|
|
|
const {access_token} = await axios.post(token_endpoint, {
|
|
|
|
const data = await axios.post(token_endpoint, JSON.stringify({
|
|
|
|
grant_type: 'password',
|
|
|
|
grant_type: 'password',
|
|
|
|
scope: 'docuware.platform',
|
|
|
|
scope: 'docuware.platform',
|
|
|
|
client_id: 'docuware.platform.net.client',
|
|
|
|
client_id: 'docuware.platform.net.client',
|
|
|
|
username, // falta añadirlos
|
|
|
|
username,
|
|
|
|
password // falta añadirlos
|
|
|
|
password
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
console.log('data: ', data);
|
|
|
|
|
|
|
|
|
|
|
|
const headers = {
|
|
|
|
const headers = {
|
|
|
|
headers: {
|
|
|
|
headers: {
|
|
|
@ -42,8 +43,8 @@ module.exports = Self => {
|
|
|
|
* @return {number} - The fileCabinet id
|
|
|
|
* @return {number} - The fileCabinet id
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
Self.getDialog = async(code, action, fileCabinetId) => {
|
|
|
|
Self.getDialog = async(code, action, fileCabinetId) => {
|
|
|
|
if (!process.env.NODE_ENV)
|
|
|
|
// if (!process.env.NODE_ENV)
|
|
|
|
return Math.floor(Math.random() + 100);
|
|
|
|
// return Math.floor(Math.random() + 100);
|
|
|
|
|
|
|
|
|
|
|
|
const docuwareInfo = await Self.app.models.Docuware.findOne({
|
|
|
|
const docuwareInfo = await Self.app.models.Docuware.findOne({
|
|
|
|
where: {
|
|
|
|
where: {
|
|
|
@ -69,8 +70,8 @@ module.exports = Self => {
|
|
|
|
* @return {number} - The fileCabinet id
|
|
|
|
* @return {number} - The fileCabinet id
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
Self.getFileCabinet = async code => {
|
|
|
|
Self.getFileCabinet = async code => {
|
|
|
|
if (!process.env.NODE_ENV)
|
|
|
|
// if (!process.env.NODE_ENV)
|
|
|
|
return Math.floor(Math.random() + 100);
|
|
|
|
// return Math.floor(Math.random() + 100);
|
|
|
|
|
|
|
|
|
|
|
|
const options = await Self.getOptions();
|
|
|
|
const options = await Self.getOptions();
|
|
|
|
const docuwareInfo = await Self.app.models.Docuware.findOne({
|
|
|
|
const docuwareInfo = await Self.app.models.Docuware.findOne({
|
|
|
@ -95,7 +96,7 @@ module.exports = Self => {
|
|
|
|
* @return {object} - The data
|
|
|
|
* @return {object} - The data
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
Self.get = async(code, filter, parse) => {
|
|
|
|
Self.get = async(code, filter, parse) => {
|
|
|
|
if (!process.env.NODE_ENV) return;
|
|
|
|
// if (!process.env.NODE_ENV) return;
|
|
|
|
|
|
|
|
|
|
|
|
const options = await Self.getOptions();
|
|
|
|
const options = await Self.getOptions();
|
|
|
|
const fileCabinetId = await Self.getFileCabinet(code);
|
|
|
|
const fileCabinetId = await Self.getFileCabinet(code);
|
|
|
@ -118,7 +119,7 @@ module.exports = Self => {
|
|
|
|
* @return {object} - The data
|
|
|
|
* @return {object} - The data
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
Self.getById = async(code, id, parse) => {
|
|
|
|
Self.getById = async(code, id, parse) => {
|
|
|
|
if (!process.env.NODE_ENV) return;
|
|
|
|
// if (!process.env.NODE_ENV) return;
|
|
|
|
|
|
|
|
|
|
|
|
const docuwareInfo = await Self.app.models.Docuware.findOne({
|
|
|
|
const docuwareInfo = await Self.app.models.Docuware.findOne({
|
|
|
|
fields: ['findById'],
|
|
|
|
fields: ['findById'],
|
|
|
|