Built motion from commit (unavailable).|2.5.27
[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 _0x6529=['admin','user','isUserLimit','crypto','composable-middleware','../../mysqldb','data1','split','createDecipher','aes-256-ctr','format','%s:%s:%s','update','base64','utf8','hasOwnProperty','findOne','then','status','json','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','users','User'];(function(_0x598eab,_0x315fca){var _0x6f8218=function(_0xb4a459){while(--_0xb4a459){_0x598eab['push'](_0x598eab['shift']());}};_0x6f8218(++_0x315fca);}(_0x6529,0x19b));var _0x9652=function(_0x1d647d,_0x197452){_0x1d647d=_0x1d647d-0x0;var _0x4454d4=_0x6529[_0x1d647d];return _0x4454d4;};'use strict';var crypto=require(_0x9652('0x0'));var util=require('util');var compose=require(_0x9652('0x1'));var db=require(_0x9652('0x2'))['db'];var config=require('../../config/environment');function getValueFromLicense(_0x25bfe3,_0x272247){if(_0x25bfe3&&_0x272247){if(_0x272247[_0x9652('0x3')]&&_0x272247['license']){var _0x450a96=_0x272247[_0x9652('0x3')];var _0x14de84=_0x272247['license'];var _0x2afe66=_0x450a96[_0x9652('0x4')]('-')[0x4];var _0x4454eb=_0x450a96[_0x9652('0x4')]('-')[0x0];var _0x581051=crypto[_0x9652('0x5')](_0x9652('0x6'),util[_0x9652('0x7')](_0x9652('0x8'),_0x2afe66,_0x450a96,_0x4454eb));var _0x3c2f0b=_0x581051[_0x9652('0x9')](_0x14de84,_0x9652('0xa'),_0x9652('0xb'));_0x3c2f0b+=_0x581051['final'](_0x9652('0xb'));var _0x5d9b71=JSON['parse'](_0x3c2f0b);return _0x5d9b71[_0x9652('0xc')](_0x25bfe3)?_0x5d9b71[_0x25bfe3]:null;}}return null;}function isLimit(_0x4199d7,_0x4062a0,_0x354451,_0x3749c7){var _0x219974=_0x4062a0;return compose()['use'](function(_0x229597,_0x39ffc4,_0x13aa39){return db['License'][_0x9652('0xd')]({'where':{'id':0x1},'raw':!![]})[_0x9652('0xe')](function(_0x5d6e04){var _0x493077=getValueFromLicense(_0x4199d7,_0x5d6e04);return _0x493077?_0x493077:_0x219974;})[_0x9652('0xe')](function(_0x2e42a5){_0x219974=_0x2e42a5;return _0x354451['count'](_0x3749c7);})[_0x9652('0xe')](function(_0x1dc7b1){if(_0x1dc7b1>=_0x219974){return _0x39ffc4[_0x9652('0xf')](0x193)[_0x9652('0x10')]({'message':util['format'](_0x9652('0x11'),_0x4199d7)});}_0x13aa39();})[_0x9652('0x12')](function(_0xf10e4a){_0x13aa39(_0xf10e4a);});});}function isUserLimit(){return isLimit(_0x9652('0x13'),0x1,db[_0x9652('0x14')],{'where':{'$or':[{'role':_0x9652('0x15')},{'role':_0x9652('0x16')}]}});}exports[_0x9652('0x17')]=isUserLimit;