92804eb790db4066ba8a56aa038a78b9c07e3122
[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 _0x3f93=['aes-256-ctr','format','%s:%s:%s','update','base64','utf8','final','parse','hasOwnProperty','use','License','findOne','then','count','status','json','catch','users','User','admin','user','isUserLimit','crypto','util','composable-middleware','../../mysqldb','../../config/environment','data1','split','createDecipher'];(function(_0x6b0731,_0x4ff682){var _0x462a9e=function(_0x168ae3){while(--_0x168ae3){_0x6b0731['push'](_0x6b0731['shift']());}};_0x462a9e(++_0x4ff682);}(_0x3f93,0xac));var _0x33f9=function(_0x2f4755,_0x72c913){_0x2f4755=_0x2f4755-0x0;var _0x375bd0=_0x3f93[_0x2f4755];return _0x375bd0;};'use strict';var crypto=require(_0x33f9('0x0'));var util=require(_0x33f9('0x1'));var compose=require(_0x33f9('0x2'));var db=require(_0x33f9('0x3'))['db'];var config=require(_0x33f9('0x4'));function getValueFromLicense(_0x2f4998,_0x7d945c){if(_0x2f4998&&_0x7d945c){if(_0x7d945c[_0x33f9('0x5')]&&_0x7d945c['license']){var _0x2cf7be=_0x7d945c[_0x33f9('0x5')];var _0x577163=_0x7d945c['license'];var _0x18c271=_0x2cf7be[_0x33f9('0x6')]('-')[0x4];var _0x26cc20=_0x2cf7be[_0x33f9('0x6')]('-')[0x0];var _0x452631=crypto[_0x33f9('0x7')](_0x33f9('0x8'),util[_0x33f9('0x9')](_0x33f9('0xa'),_0x18c271,_0x2cf7be,_0x26cc20));var _0x1747da=_0x452631[_0x33f9('0xb')](_0x577163,_0x33f9('0xc'),_0x33f9('0xd'));_0x1747da+=_0x452631[_0x33f9('0xe')]('utf8');var _0x12061e=JSON[_0x33f9('0xf')](_0x1747da);return _0x12061e[_0x33f9('0x10')](_0x2f4998)?_0x12061e[_0x2f4998]:null;}}return null;}function isLimit(_0xb78d10,_0x773313,_0x92e6da,_0x273981){var _0x4d8071=_0x773313;return compose()[_0x33f9('0x11')](function(_0xaf9874,_0x3d3f13,_0x5c6046){return db[_0x33f9('0x12')][_0x33f9('0x13')]({'where':{'id':0x1},'raw':!![]})[_0x33f9('0x14')](function(_0x10ec70){var _0xd85528=getValueFromLicense(_0xb78d10,_0x10ec70);return _0xd85528?_0xd85528:_0x4d8071;})['then'](function(_0x5952ac){_0x4d8071=_0x5952ac;return _0x92e6da[_0x33f9('0x15')](_0x273981);})['then'](function(_0x31205c){if(_0x31205c>=_0x4d8071){return _0x3d3f13[_0x33f9('0x16')](0x193)[_0x33f9('0x17')]({'message':util['format']('Maximum\x20%s\x20limit\x20have\x20been\x20reached',_0xb78d10)});}_0x5c6046();})[_0x33f9('0x18')](function(_0x43ab30){_0x5c6046(_0x43ab30);});});}function isUserLimit(){return isLimit(_0x33f9('0x19'),0x1,db[_0x33f9('0x1a')],{'where':{'$or':[{'role':_0x33f9('0x1b')},{'role':_0x33f9('0x1c')}]}});}exports[_0x33f9('0x1d')]=isUserLimit;