eb74693b7b8a345f509208a4996401ce1b7b8e09
[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 _0xf536=['findOne','then','count','status','json','catch','users','User','user','crypto','util','composable-middleware','../../mysqldb','../../config/environment','data1','license','split','createDecipher','format','%s:%s:%s','update','base64','utf8','final','parse','hasOwnProperty','use','License'];(function(_0x41d1b1,_0x30a3b7){var _0x55bd34=function(_0x569713){while(--_0x569713){_0x41d1b1['push'](_0x41d1b1['shift']());}};_0x55bd34(++_0x30a3b7);}(_0xf536,0x159));var _0x6f53=function(_0x1440ce,_0x136aee){_0x1440ce=_0x1440ce-0x0;var _0x389c35=_0xf536[_0x1440ce];return _0x389c35;};'use strict';var crypto=require(_0x6f53('0x0'));var util=require(_0x6f53('0x1'));var compose=require(_0x6f53('0x2'));var db=require(_0x6f53('0x3'))['db'];var config=require(_0x6f53('0x4'));function getValueFromLicense(_0x406eae,_0x5dc58a){if(_0x406eae&&_0x5dc58a){if(_0x5dc58a[_0x6f53('0x5')]&&_0x5dc58a[_0x6f53('0x6')]){var _0x589017=_0x5dc58a[_0x6f53('0x5')];var _0x347aea=_0x5dc58a[_0x6f53('0x6')];var _0x12d685=_0x589017[_0x6f53('0x7')]('-')[0x4];var _0x5512d8=_0x589017['split']('-')[0x0];var _0x4be1de=crypto[_0x6f53('0x8')]('aes-256-ctr',util[_0x6f53('0x9')](_0x6f53('0xa'),_0x12d685,_0x589017,_0x5512d8));var _0x109bb8=_0x4be1de[_0x6f53('0xb')](_0x347aea,_0x6f53('0xc'),_0x6f53('0xd'));_0x109bb8+=_0x4be1de[_0x6f53('0xe')](_0x6f53('0xd'));var _0x590cf7=JSON[_0x6f53('0xf')](_0x109bb8);return _0x590cf7[_0x6f53('0x10')](_0x406eae)?_0x590cf7[_0x406eae]:null;}}return null;}function isLimit(_0xc26a8a,_0x35b9af,_0x24772c,_0x1f1025){var _0x50cef1=_0x35b9af;return compose()[_0x6f53('0x11')](function(_0x350a32,_0x36b423,_0x158921){return db[_0x6f53('0x12')][_0x6f53('0x13')]({'where':{'id':0x1},'raw':!![]})[_0x6f53('0x14')](function(_0x1b5f94){var _0x290470=getValueFromLicense(_0xc26a8a,_0x1b5f94);return _0x290470?_0x290470:_0x50cef1;})['then'](function(_0x10607d){_0x50cef1=_0x10607d;return _0x24772c[_0x6f53('0x15')](_0x1f1025);})['then'](function(_0x34364f){if(_0x34364f>=_0x50cef1){return _0x36b423[_0x6f53('0x16')](0x193)[_0x6f53('0x17')]({'message':util[_0x6f53('0x9')]('Maximum\x20%s\x20limit\x20have\x20been\x20reached',_0xc26a8a)});}_0x158921();})[_0x6f53('0x18')](function(_0x29940c){_0x158921(_0x29940c);});});}function isUserLimit(){return isLimit(_0x6f53('0x19'),0x1,db[_0x6f53('0x1a')],{'where':{'$or':[{'role':'admin'},{'role':_0x6f53('0x1b')}]}});}exports['isUserLimit']=isUserLimit;