Built motion from commit ddca4d0d.|2.5.47
[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 _0x7b3b=['users','User','isUserLimit','crypto','util','composable-middleware','../../mysqldb','../../config/environment','data1','license','split','createDecipher','aes-256-ctr','format','%s:%s:%s','update','base64','final','utf8','parse','hasOwnProperty','use','License','findOne','then','count','status','json','Maximum\x20%s\x20limit\x20have\x20been\x20reached'];(function(_0x46e94c,_0x461216){var _0x597221=function(_0x17b6d9){while(--_0x17b6d9){_0x46e94c['push'](_0x46e94c['shift']());}};_0x597221(++_0x461216);}(_0x7b3b,0x199));var _0xb7b3=function(_0x45835c,_0x323e18){_0x45835c=_0x45835c-0x0;var _0x13865e=_0x7b3b[_0x45835c];return _0x13865e;};'use strict';var crypto=require(_0xb7b3('0x0'));var util=require(_0xb7b3('0x1'));var compose=require(_0xb7b3('0x2'));var db=require(_0xb7b3('0x3'))['db'];var config=require(_0xb7b3('0x4'));function getValueFromLicense(_0x382efa,_0x1244a7){if(_0x382efa&&_0x1244a7){if(_0x1244a7[_0xb7b3('0x5')]&&_0x1244a7[_0xb7b3('0x6')]){var _0x33e54e=_0x1244a7[_0xb7b3('0x5')];var _0x55ce0d=_0x1244a7[_0xb7b3('0x6')];var _0x543447=_0x33e54e[_0xb7b3('0x7')]('-')[0x4];var _0x2c2a76=_0x33e54e[_0xb7b3('0x7')]('-')[0x0];var _0x523f5e=crypto[_0xb7b3('0x8')](_0xb7b3('0x9'),util[_0xb7b3('0xa')](_0xb7b3('0xb'),_0x543447,_0x33e54e,_0x2c2a76));var _0x2f4628=_0x523f5e[_0xb7b3('0xc')](_0x55ce0d,_0xb7b3('0xd'),'utf8');_0x2f4628+=_0x523f5e[_0xb7b3('0xe')](_0xb7b3('0xf'));var _0x302d16=JSON[_0xb7b3('0x10')](_0x2f4628);return _0x302d16[_0xb7b3('0x11')](_0x382efa)?_0x302d16[_0x382efa]:null;}}return null;}function isLimit(_0x2a3b91,_0xf77aac,_0x52c048,_0x365199){var _0x14db11=_0xf77aac;return compose()[_0xb7b3('0x12')](function(_0x364cd3,_0x2b3a42,_0xa1556){return db[_0xb7b3('0x13')][_0xb7b3('0x14')]({'where':{'id':0x1},'raw':!![]})['then'](function(_0x8a3c9c){var _0x19980a=getValueFromLicense(_0x2a3b91,_0x8a3c9c);return _0x19980a?_0x19980a:_0x14db11;})[_0xb7b3('0x15')](function(_0x58cb64){_0x14db11=_0x58cb64;return _0x52c048[_0xb7b3('0x16')](_0x365199);})['then'](function(_0x211403){if(_0x211403>=_0x14db11){return _0x2b3a42[_0xb7b3('0x17')](0x193)[_0xb7b3('0x18')]({'message':util[_0xb7b3('0xa')](_0xb7b3('0x19'),_0x2a3b91)});}_0xa1556();})['catch'](function(_0x433430){_0xa1556(_0x433430);});});}function isUserLimit(){return isLimit(_0xb7b3('0x1a'),0x1,db[_0xb7b3('0x1b')],{'where':{'$or':[{'role':'admin'},{'role':'user'}]}});}exports[_0xb7b3('0x1c')]=isUserLimit;