Built motion from commit (unavailable).|2.5.29
[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 _0x3ffa=['format','%s:%s:%s','update','final','utf8','parse','hasOwnProperty','use','License','findOne','then','count','status','json','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','users','User','admin','crypto','util','composable-middleware','../../mysqldb','../../config/environment','data1','license','split','createDecipher','aes-256-ctr'];(function(_0x5341ff,_0x1de6df){var _0x53be58=function(_0x4da0da){while(--_0x4da0da){_0x5341ff['push'](_0x5341ff['shift']());}};_0x53be58(++_0x1de6df);}(_0x3ffa,0x118));var _0xa3ff=function(_0x50b87f,_0xbeedf0){_0x50b87f=_0x50b87f-0x0;var _0x5b120f=_0x3ffa[_0x50b87f];return _0x5b120f;};'use strict';var crypto=require(_0xa3ff('0x0'));var util=require(_0xa3ff('0x1'));var compose=require(_0xa3ff('0x2'));var db=require(_0xa3ff('0x3'))['db'];var config=require(_0xa3ff('0x4'));function getValueFromLicense(_0xf9a45f,_0x1fe0de){if(_0xf9a45f&&_0x1fe0de){if(_0x1fe0de[_0xa3ff('0x5')]&&_0x1fe0de[_0xa3ff('0x6')]){var _0x568c1b=_0x1fe0de[_0xa3ff('0x5')];var _0x9cf6eb=_0x1fe0de[_0xa3ff('0x6')];var _0x98776c=_0x568c1b[_0xa3ff('0x7')]('-')[0x4];var _0x26ceec=_0x568c1b[_0xa3ff('0x7')]('-')[0x0];var _0x1317ac=crypto[_0xa3ff('0x8')](_0xa3ff('0x9'),util[_0xa3ff('0xa')](_0xa3ff('0xb'),_0x98776c,_0x568c1b,_0x26ceec));var _0x40d708=_0x1317ac[_0xa3ff('0xc')](_0x9cf6eb,'base64','utf8');_0x40d708+=_0x1317ac[_0xa3ff('0xd')](_0xa3ff('0xe'));var _0x14b4ce=JSON[_0xa3ff('0xf')](_0x40d708);return _0x14b4ce[_0xa3ff('0x10')](_0xf9a45f)?_0x14b4ce[_0xf9a45f]:null;}}return null;}function isLimit(_0x5df520,_0x58bd05,_0x52d6ee,_0x57df7e){var _0x346088=_0x58bd05;return compose()[_0xa3ff('0x11')](function(_0x10af30,_0x21a95c,_0x971296){return db[_0xa3ff('0x12')][_0xa3ff('0x13')]({'where':{'id':0x1},'raw':!![]})[_0xa3ff('0x14')](function(_0xa9b20c){var _0x176812=getValueFromLicense(_0x5df520,_0xa9b20c);return _0x176812?_0x176812:_0x346088;})[_0xa3ff('0x14')](function(_0x1bc217){_0x346088=_0x1bc217;return _0x52d6ee[_0xa3ff('0x15')](_0x57df7e);})[_0xa3ff('0x14')](function(_0x42c162){if(_0x42c162>=_0x346088){return _0x21a95c[_0xa3ff('0x16')](0x193)[_0xa3ff('0x17')]({'message':util['format'](_0xa3ff('0x18'),_0x5df520)});}_0x971296();})[_0xa3ff('0x19')](function(_0x3a80d8){_0x971296(_0x3a80d8);});});}function isUserLimit(){return isLimit(_0xa3ff('0x1a'),0x1,db[_0xa3ff('0x1b')],{'where':{'$or':[{'role':_0xa3ff('0x1c')},{'role':'user'}]}});}exports['isUserLimit']=isUserLimit;