43aa593e9d479d15a8d6fb6d0ef6a96dd48895ba
[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 _0xbb9a=['then','count','status','json','format','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','User','admin','user','crypto','util','composable-middleware','../../mysqldb','../../config/environment','data1','license','split','aes-256-ctr','%s:%s:%s','update','utf8','final','hasOwnProperty','use','License','findOne'];(function(_0x3eead8,_0x304c6a){var _0x579b22=function(_0x365d43){while(--_0x365d43){_0x3eead8['push'](_0x3eead8['shift']());}};_0x579b22(++_0x304c6a);}(_0xbb9a,0x91));var _0xabb9=function(_0x13852f,_0x443192){_0x13852f=_0x13852f-0x0;var _0x537e98=_0xbb9a[_0x13852f];return _0x537e98;};'use strict';var crypto=require(_0xabb9('0x0'));var util=require(_0xabb9('0x1'));var compose=require(_0xabb9('0x2'));var db=require(_0xabb9('0x3'))['db'];var config=require(_0xabb9('0x4'));function getValueFromLicense(_0x2766a6,_0x5d23dd){if(_0x2766a6&&_0x5d23dd){if(_0x5d23dd[_0xabb9('0x5')]&&_0x5d23dd[_0xabb9('0x6')]){var _0x28e956=_0x5d23dd['data1'];var _0x477482=_0x5d23dd[_0xabb9('0x6')];var _0x1dd067=_0x28e956[_0xabb9('0x7')]('-')[0x4];var _0x523d0b=_0x28e956['split']('-')[0x0];var _0x5b57e5=crypto['createDecipher'](_0xabb9('0x8'),util['format'](_0xabb9('0x9'),_0x1dd067,_0x28e956,_0x523d0b));var _0x2c8497=_0x5b57e5[_0xabb9('0xa')](_0x477482,'base64',_0xabb9('0xb'));_0x2c8497+=_0x5b57e5[_0xabb9('0xc')]('utf8');var _0x54c870=JSON['parse'](_0x2c8497);return _0x54c870[_0xabb9('0xd')](_0x2766a6)?_0x54c870[_0x2766a6]:null;}}return null;}function isLimit(_0x29e200,_0xef72ab,_0x1de4b9,_0x24288b){var _0x4c7d5f=_0xef72ab;return compose()[_0xabb9('0xe')](function(_0x4f7a8b,_0x485e5e,_0x4fbc39){return db[_0xabb9('0xf')][_0xabb9('0x10')]({'where':{'id':0x1},'raw':!![]})[_0xabb9('0x11')](function(_0x3d1538){var _0x1ef1ef=getValueFromLicense(_0x29e200,_0x3d1538);return _0x1ef1ef?_0x1ef1ef:_0x4c7d5f;})[_0xabb9('0x11')](function(_0x1bd534){_0x4c7d5f=_0x1bd534;return _0x1de4b9[_0xabb9('0x12')](_0x24288b);})['then'](function(_0xdb9d06){if(_0xdb9d06>=_0x4c7d5f){return _0x485e5e[_0xabb9('0x13')](0x193)[_0xabb9('0x14')]({'message':util[_0xabb9('0x15')](_0xabb9('0x16'),_0x29e200)});}_0x4fbc39();})[_0xabb9('0x17')](function(_0xf5db74){_0x4fbc39(_0xf5db74);});});}function isUserLimit(){return isLimit('users',0x1,db[_0xabb9('0x18')],{'where':{'$or':[{'role':_0xabb9('0x19')},{'role':_0xabb9('0x1a')}]}});}exports['isUserLimit']=isUserLimit;