Built motion from commit bbec7235.|2.6.20
[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 _0x7e69=['../../config/environment','data1','license','split','createDecipher','aes-256-ctr','format','update','base64','final','utf8','hasOwnProperty','use','License','findOne','then','count','json','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','users','user','crypto','util','composable-middleware','../../mysqldb'];(function(_0x39c439,_0x35bab7){var _0x16469f=function(_0x59d364){while(--_0x59d364){_0x39c439['push'](_0x39c439['shift']());}};_0x16469f(++_0x35bab7);}(_0x7e69,0x64));var _0x97e6=function(_0x35cc99,_0x5bb972){_0x35cc99=_0x35cc99-0x0;var _0x14373c=_0x7e69[_0x35cc99];return _0x14373c;};'use strict';var crypto=require(_0x97e6('0x0'));var util=require(_0x97e6('0x1'));var compose=require(_0x97e6('0x2'));var db=require(_0x97e6('0x3'))['db'];var config=require(_0x97e6('0x4'));function getValueFromLicense(_0x2bde74,_0x26a223){if(_0x2bde74&&_0x26a223){if(_0x26a223[_0x97e6('0x5')]&&_0x26a223[_0x97e6('0x6')]){var _0x4e4241=_0x26a223[_0x97e6('0x5')];var _0x5a604d=_0x26a223[_0x97e6('0x6')];var _0x2c6308=_0x4e4241[_0x97e6('0x7')]('-')[0x4];var _0x1d2c69=_0x4e4241['split']('-')[0x0];var _0x3e01ea=crypto[_0x97e6('0x8')](_0x97e6('0x9'),util[_0x97e6('0xa')]('%s:%s:%s',_0x2c6308,_0x4e4241,_0x1d2c69));var _0x23eb9b=_0x3e01ea[_0x97e6('0xb')](_0x5a604d,_0x97e6('0xc'),'utf8');_0x23eb9b+=_0x3e01ea[_0x97e6('0xd')](_0x97e6('0xe'));var _0x56165a=JSON['parse'](_0x23eb9b);return _0x56165a[_0x97e6('0xf')](_0x2bde74)?_0x56165a[_0x2bde74]:null;}}return null;}function isLimit(_0x401a6d,_0x2120df,_0x5a9601,_0x22feb5){var _0x1c5b42=_0x2120df;return compose()[_0x97e6('0x10')](function(_0x2f868a,_0x4a6f85,_0x4bb124){return db[_0x97e6('0x11')][_0x97e6('0x12')]({'where':{'id':0x1},'raw':!![]})[_0x97e6('0x13')](function(_0x5e4b7a){var _0xcfbdd1=getValueFromLicense(_0x401a6d,_0x5e4b7a);return _0xcfbdd1?_0xcfbdd1:_0x1c5b42;})['then'](function(_0x319150){_0x1c5b42=_0x319150;return _0x5a9601[_0x97e6('0x14')](_0x22feb5);})[_0x97e6('0x13')](function(_0xc5a30f){if(_0xc5a30f>=_0x1c5b42){return _0x4a6f85['status'](0x193)[_0x97e6('0x15')]({'message':util['format'](_0x97e6('0x16'),_0x401a6d)});}_0x4bb124();})[_0x97e6('0x17')](function(_0x44bb8c){_0x4bb124(_0x44bb8c);});});}function isUserLimit(){return isLimit(_0x97e6('0x18'),0x1,db['User'],{'where':{'$or':[{'role':'admin'},{'role':_0x97e6('0x19')}]}});}exports['isUserLimit']=isUserLimit;