Built motion from commit (unavailable).|2.5.8
[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 _0x039d=['data1','license','createDecipher','aes-256-ctr','format','%s:%s:%s','update','base64','utf8','final','parse','License','findOne','then','count','status','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','users','User','user','util','composable-middleware','../../mysqldb','../../config/environment'];(function(_0x24210c,_0x4d1505){var _0x2a0469=function(_0x489bce){while(--_0x489bce){_0x24210c['push'](_0x24210c['shift']());}};_0x2a0469(++_0x4d1505);}(_0x039d,0x1d7));var _0xd039=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0x039d[_0x321bb2];return _0x9c12ed;};'use strict';var crypto=require('crypto');var util=require(_0xd039('0x0'));var compose=require(_0xd039('0x1'));var db=require(_0xd039('0x2'))['db'];var config=require(_0xd039('0x3'));function getValueFromLicense(_0x219ed5,_0x1dd5bd){if(_0x219ed5&&_0x1dd5bd){if(_0x1dd5bd[_0xd039('0x4')]&&_0x1dd5bd[_0xd039('0x5')]){var _0x44fc05=_0x1dd5bd[_0xd039('0x4')];var _0x5a57e7=_0x1dd5bd[_0xd039('0x5')];var _0x442f79=_0x44fc05['split']('-')[0x4];var _0x201cb3=_0x44fc05['split']('-')[0x0];var _0xdc203a=crypto[_0xd039('0x6')](_0xd039('0x7'),util[_0xd039('0x8')](_0xd039('0x9'),_0x442f79,_0x44fc05,_0x201cb3));var _0x4530a4=_0xdc203a[_0xd039('0xa')](_0x5a57e7,_0xd039('0xb'),_0xd039('0xc'));_0x4530a4+=_0xdc203a[_0xd039('0xd')](_0xd039('0xc'));var _0x467f19=JSON[_0xd039('0xe')](_0x4530a4);return _0x467f19['hasOwnProperty'](_0x219ed5)?_0x467f19[_0x219ed5]:null;}}return null;}function isLimit(_0x18f151,_0x2a21f5,_0x1e0f3c,_0x9b277c){var _0x2c1757=_0x2a21f5;return compose()['use'](function(_0x1ad7be,_0x58f6d8,_0x117c90){return db[_0xd039('0xf')][_0xd039('0x10')]({'where':{'id':0x1},'raw':!![]})['then'](function(_0xbeb6f0){var _0x1edb30=getValueFromLicense(_0x18f151,_0xbeb6f0);return _0x1edb30?_0x1edb30:_0x2c1757;})[_0xd039('0x11')](function(_0x1275c4){_0x2c1757=_0x1275c4;return _0x1e0f3c[_0xd039('0x12')](_0x9b277c);})['then'](function(_0x23238f){if(_0x23238f>=_0x2c1757){return _0x58f6d8[_0xd039('0x13')](0x193)['json']({'message':util[_0xd039('0x8')](_0xd039('0x14'),_0x18f151)});}_0x117c90();})[_0xd039('0x15')](function(_0x3eefe1){_0x117c90(_0x3eefe1);});});}function isUserLimit(){return isLimit(_0xd039('0x16'),0x1,db[_0xd039('0x17')],{'where':{'$or':[{'role':'admin'},{'role':_0xd039('0x18')}]}});}exports['isUserLimit']=isUserLimit;