Built motion from commit b0a9a629.|2.6.33
[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 _0x5430=['utf8','final','parse','hasOwnProperty','use','License','findOne','then','count','status','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','users','admin','user','isUserLimit','crypto','composable-middleware','../../mysqldb','data1','license','split','createDecipher','aes-256-ctr','format','%s:%s:%s','base64'];(function(_0x1aad46,_0x2f8769){var _0x22de99=function(_0x1d05fe){while(--_0x1d05fe){_0x1aad46['push'](_0x1aad46['shift']());}};_0x22de99(++_0x2f8769);}(_0x5430,0x16f));var _0x0543=function(_0x1f242e,_0x1a136f){_0x1f242e=_0x1f242e-0x0;var _0x39829b=_0x5430[_0x1f242e];return _0x39829b;};'use strict';var crypto=require(_0x0543('0x0'));var util=require('util');var compose=require(_0x0543('0x1'));var db=require(_0x0543('0x2'))['db'];var config=require('../../config/environment');function getValueFromLicense(_0x4104fb,_0x1fef48){if(_0x4104fb&&_0x1fef48){if(_0x1fef48['data1']&&_0x1fef48['license']){var _0x5cd198=_0x1fef48[_0x0543('0x3')];var _0x53347c=_0x1fef48[_0x0543('0x4')];var _0x270144=_0x5cd198['split']('-')[0x4];var _0xf922=_0x5cd198[_0x0543('0x5')]('-')[0x0];var _0x471030=crypto[_0x0543('0x6')](_0x0543('0x7'),util[_0x0543('0x8')](_0x0543('0x9'),_0x270144,_0x5cd198,_0xf922));var _0x60d60e=_0x471030['update'](_0x53347c,_0x0543('0xa'),_0x0543('0xb'));_0x60d60e+=_0x471030[_0x0543('0xc')](_0x0543('0xb'));var _0x38f071=JSON[_0x0543('0xd')](_0x60d60e);return _0x38f071[_0x0543('0xe')](_0x4104fb)?_0x38f071[_0x4104fb]:null;}}return null;}function isLimit(_0xf873c6,_0x4c12de,_0x26a697,_0x565a5c){var _0x51235e=_0x4c12de;return compose()[_0x0543('0xf')](function(_0x10e7b6,_0x50194e,_0x488882){return db[_0x0543('0x10')][_0x0543('0x11')]({'where':{'id':0x1},'raw':!![]})[_0x0543('0x12')](function(_0x353e55){var _0x93c167=getValueFromLicense(_0xf873c6,_0x353e55);return _0x93c167?_0x93c167:_0x51235e;})[_0x0543('0x12')](function(_0x4c4bc8){_0x51235e=_0x4c4bc8;return _0x26a697[_0x0543('0x13')](_0x565a5c);})['then'](function(_0x17ea2e){if(_0x17ea2e>=_0x51235e){return _0x50194e[_0x0543('0x14')](0x193)['json']({'message':util[_0x0543('0x8')](_0x0543('0x15'),_0xf873c6)});}_0x488882();})[_0x0543('0x16')](function(_0x306b1f){_0x488882(_0x306b1f);});});}function isUserLimit(){return isLimit(_0x0543('0x17'),0x1,db['User'],{'where':{'$or':[{'role':_0x0543('0x18')},{'role':_0x0543('0x19')}]}});}exports[_0x0543('0x1a')]=isUserLimit;