0a9ff4088b662db27fc7a83587f859d17b4d4dab
[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 _0xcd6f=['final','parse','hasOwnProperty','use','License','findOne','then','count','status','json','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','users','User','isUserLimit','crypto','util','composable-middleware','../../mysqldb','../../config/environment','data1','license','split','createDecipher','aes-256-ctr','format','%s:%s:%s','update','base64','utf8'];(function(_0x595a3c,_0x45d7d3){var _0x2552f1=function(_0x443cd8){while(--_0x443cd8){_0x595a3c['push'](_0x595a3c['shift']());}};_0x2552f1(++_0x45d7d3);}(_0xcd6f,0x11d));var _0xfcd6=function(_0x17848d,_0x2c71fa){_0x17848d=_0x17848d-0x0;var _0x467214=_0xcd6f[_0x17848d];return _0x467214;};'use strict';var crypto=require(_0xfcd6('0x0'));var util=require(_0xfcd6('0x1'));var compose=require(_0xfcd6('0x2'));var db=require(_0xfcd6('0x3'))['db'];var config=require(_0xfcd6('0x4'));function getValueFromLicense(_0x1b454f,_0x30ba28){if(_0x1b454f&&_0x30ba28){if(_0x30ba28[_0xfcd6('0x5')]&&_0x30ba28[_0xfcd6('0x6')]){var _0x1799b3=_0x30ba28['data1'];var _0x380932=_0x30ba28[_0xfcd6('0x6')];var _0x13babe=_0x1799b3[_0xfcd6('0x7')]('-')[0x4];var _0x1523ea=_0x1799b3[_0xfcd6('0x7')]('-')[0x0];var _0x3bdb51=crypto[_0xfcd6('0x8')](_0xfcd6('0x9'),util[_0xfcd6('0xa')](_0xfcd6('0xb'),_0x13babe,_0x1799b3,_0x1523ea));var _0x24e617=_0x3bdb51[_0xfcd6('0xc')](_0x380932,_0xfcd6('0xd'),_0xfcd6('0xe'));_0x24e617+=_0x3bdb51[_0xfcd6('0xf')](_0xfcd6('0xe'));var _0x2c27e7=JSON[_0xfcd6('0x10')](_0x24e617);return _0x2c27e7[_0xfcd6('0x11')](_0x1b454f)?_0x2c27e7[_0x1b454f]:null;}}return null;}function isLimit(_0x336e52,_0x3b8320,_0x484b2e,_0x44de90){var _0x1ffe5c=_0x3b8320;return compose()[_0xfcd6('0x12')](function(_0x124730,_0x46b389,_0x35fddd){return db[_0xfcd6('0x13')][_0xfcd6('0x14')]({'where':{'id':0x1},'raw':!![]})[_0xfcd6('0x15')](function(_0x56c7cf){var _0x50d148=getValueFromLicense(_0x336e52,_0x56c7cf);return _0x50d148?_0x50d148:_0x1ffe5c;})[_0xfcd6('0x15')](function(_0x48a010){_0x1ffe5c=_0x48a010;return _0x484b2e[_0xfcd6('0x16')](_0x44de90);})['then'](function(_0x132013){if(_0x132013>=_0x1ffe5c){return _0x46b389[_0xfcd6('0x17')](0x193)[_0xfcd6('0x18')]({'message':util['format'](_0xfcd6('0x19'),_0x336e52)});}_0x35fddd();})[_0xfcd6('0x1a')](function(_0x4923de){_0x35fddd(_0x4923de);});});}function isUserLimit(){return isLimit(_0xfcd6('0x1b'),0x1,db[_0xfcd6('0x1c')],{'where':{'$or':[{'role':'admin'},{'role':'user'}]}});}exports[_0xfcd6('0x1d')]=isUserLimit;