28e51d5a529ff083f17309018c39e7366d6e0010
[motion2.git] / server / components / license / service.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x7437=['base64','utf8','final','parse','hasOwnProperty','License','findOne','then','count','status','json','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','User','crypto','util','composable-middleware','../../mysqldb','../../config/environment','data1','license','split','createDecipher','aes-256-ctr','format','%s:%s:%s','update'];(function(_0x401a51,_0x11ca2f){var _0x46ced8=function(_0x257af5){while(--_0x257af5){_0x401a51['push'](_0x401a51['shift']());}};_0x46ced8(++_0x11ca2f);}(_0x7437,0xe6));var _0x7743=function(_0x323430,_0x3d2b6d){_0x323430=_0x323430-0x0;var _0x9eecd1=_0x7437[_0x323430];return _0x9eecd1;};'use strict';var crypto=require(_0x7743('0x0'));var util=require(_0x7743('0x1'));var compose=require(_0x7743('0x2'));var db=require(_0x7743('0x3'))['db'];var config=require(_0x7743('0x4'));function getValueFromLicense(_0x2436a4,_0x2ab96c){if(_0x2436a4&&_0x2ab96c){if(_0x2ab96c[_0x7743('0x5')]&&_0x2ab96c[_0x7743('0x6')]){var _0x51f098=_0x2ab96c[_0x7743('0x5')];var _0x22e95a=_0x2ab96c['license'];var _0x5bde2e=_0x51f098['split']('-')[0x4];var _0x5a2129=_0x51f098[_0x7743('0x7')]('-')[0x0];var _0x2da6f7=crypto[_0x7743('0x8')](_0x7743('0x9'),util[_0x7743('0xa')](_0x7743('0xb'),_0x5bde2e,_0x51f098,_0x5a2129));var _0x19998e=_0x2da6f7[_0x7743('0xc')](_0x22e95a,_0x7743('0xd'),_0x7743('0xe'));_0x19998e+=_0x2da6f7[_0x7743('0xf')](_0x7743('0xe'));var _0x4273a4=JSON[_0x7743('0x10')](_0x19998e);return _0x4273a4[_0x7743('0x11')](_0x2436a4)?_0x4273a4[_0x2436a4]:null;}}return null;}function isLimit(_0x311d01,_0x3773cf,_0x2a1398,_0x58f989){var _0x374c8e=_0x3773cf;return compose()['use'](function(_0x408f43,_0x58553d,_0x24ae63){return db[_0x7743('0x12')][_0x7743('0x13')]({'where':{'id':0x1},'raw':!![]})[_0x7743('0x14')](function(_0x394dda){var _0x5eb20e=getValueFromLicense(_0x311d01,_0x394dda);return _0x5eb20e?_0x5eb20e:_0x374c8e;})['then'](function(_0x471fe4){_0x374c8e=_0x471fe4;return _0x2a1398[_0x7743('0x15')](_0x58f989);})['then'](function(_0x507db8){if(_0x507db8>=_0x374c8e){return _0x58553d[_0x7743('0x16')](0x193)[_0x7743('0x17')]({'message':util[_0x7743('0xa')](_0x7743('0x18'),_0x311d01)});}_0x24ae63();})[_0x7743('0x19')](function(_0x3087c8){_0x24ae63(_0x3087c8);});});}function isUserLimit(){return isLimit('users',0x1,db[_0x7743('0x1a')],{'where':{'$or':[{'role':'admin'},{'role':'user'}]}});}exports['isUserLimit']=isUserLimit;