Built motion from commit a8c4dd89.|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 _0xec82=['split','createDecipher','format','%s:%s:%s','update','base64','utf8','final','hasOwnProperty','use','License','findOne','then','json','Maximum\x20%s\x20limit\x20have\x20been\x20reached','users','User','crypto','composable-middleware','../../mysqldb','data1','license'];(function(_0x273b7e,_0x1b642f){var _0x5df145=function(_0x58e003){while(--_0x58e003){_0x273b7e['push'](_0x273b7e['shift']());}};_0x5df145(++_0x1b642f);}(_0xec82,0x95));var _0x2ec8=function(_0xccac79,_0x30c43c){_0xccac79=_0xccac79-0x0;var _0x3776cf=_0xec82[_0xccac79];return _0x3776cf;};'use strict';var crypto=require(_0x2ec8('0x0'));var util=require('util');var compose=require(_0x2ec8('0x1'));var db=require(_0x2ec8('0x2'))['db'];var config=require('../../config/environment');function getValueFromLicense(_0x5e247e,_0x59d330){if(_0x5e247e&&_0x59d330){if(_0x59d330[_0x2ec8('0x3')]&&_0x59d330['license']){var _0x5c2e16=_0x59d330['data1'];var _0x72df4d=_0x59d330[_0x2ec8('0x4')];var _0x6263b9=_0x5c2e16[_0x2ec8('0x5')]('-')[0x4];var _0x44b152=_0x5c2e16[_0x2ec8('0x5')]('-')[0x0];var _0x4c3c37=crypto[_0x2ec8('0x6')]('aes-256-ctr',util[_0x2ec8('0x7')](_0x2ec8('0x8'),_0x6263b9,_0x5c2e16,_0x44b152));var _0x598c03=_0x4c3c37[_0x2ec8('0x9')](_0x72df4d,_0x2ec8('0xa'),_0x2ec8('0xb'));_0x598c03+=_0x4c3c37[_0x2ec8('0xc')]('utf8');var _0x3839a7=JSON['parse'](_0x598c03);return _0x3839a7[_0x2ec8('0xd')](_0x5e247e)?_0x3839a7[_0x5e247e]:null;}}return null;}function isLimit(_0x2fda5b,_0x53b607,_0x48315e,_0x10a091){var _0x5acae7=_0x53b607;return compose()[_0x2ec8('0xe')](function(_0x14486b,_0x4d0f5b,_0xd26761){return db[_0x2ec8('0xf')][_0x2ec8('0x10')]({'where':{'id':0x1},'raw':!![]})[_0x2ec8('0x11')](function(_0x393918){var _0x2abe27=getValueFromLicense(_0x2fda5b,_0x393918);return _0x2abe27?_0x2abe27:_0x5acae7;})[_0x2ec8('0x11')](function(_0x19ef0d){_0x5acae7=_0x19ef0d;return _0x48315e['count'](_0x10a091);})[_0x2ec8('0x11')](function(_0x5983cd){if(_0x5983cd>=_0x5acae7){return _0x4d0f5b['status'](0x193)[_0x2ec8('0x12')]({'message':util['format'](_0x2ec8('0x13'),_0x2fda5b)});}_0xd26761();})['catch'](function(_0xfc8335){_0xd26761(_0xfc8335);});});}function isUserLimit(){return isLimit(_0x2ec8('0x14'),0x1,db[_0x2ec8('0x15')],{'where':{'$or':[{'role':'admin'},{'role':'user'}]}});}exports['isUserLimit']=isUserLimit;