660ef11ac2296a5fa9820db2390b3f781efb4d96
[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 _0x84dd=['format','users','User','admin','user','isUserLimit','crypto','util','composable-middleware','../../mysqldb','../../config/environment','data1','license','split','%s:%s:%s','update','base64','utf8','final','parse','hasOwnProperty','use','License','findOne','then','count','status','json'];(function(_0x28958d,_0xfa5f9f){var _0x439c72=function(_0x280df5){while(--_0x280df5){_0x28958d['push'](_0x28958d['shift']());}};_0x439c72(++_0xfa5f9f);}(_0x84dd,0x172));var _0xd84d=function(_0x517859,_0x206584){_0x517859=_0x517859-0x0;var _0x9acf12=_0x84dd[_0x517859];return _0x9acf12;};'use strict';var crypto=require(_0xd84d('0x0'));var util=require(_0xd84d('0x1'));var compose=require(_0xd84d('0x2'));var db=require(_0xd84d('0x3'))['db'];var config=require(_0xd84d('0x4'));function getValueFromLicense(_0x56ead,_0x5d556e){if(_0x56ead&&_0x5d556e){if(_0x5d556e[_0xd84d('0x5')]&&_0x5d556e[_0xd84d('0x6')]){var _0x188bf2=_0x5d556e[_0xd84d('0x5')];var _0x4db25=_0x5d556e[_0xd84d('0x6')];var _0x4eabd1=_0x188bf2[_0xd84d('0x7')]('-')[0x4];var _0x20f800=_0x188bf2['split']('-')[0x0];var _0x165de6=crypto['createDecipher']('aes-256-ctr',util['format'](_0xd84d('0x8'),_0x4eabd1,_0x188bf2,_0x20f800));var _0x1e71c6=_0x165de6[_0xd84d('0x9')](_0x4db25,_0xd84d('0xa'),_0xd84d('0xb'));_0x1e71c6+=_0x165de6[_0xd84d('0xc')](_0xd84d('0xb'));var _0x56491a=JSON[_0xd84d('0xd')](_0x1e71c6);return _0x56491a[_0xd84d('0xe')](_0x56ead)?_0x56491a[_0x56ead]:null;}}return null;}function isLimit(_0x224cf7,_0x8c18df,_0x2e4bc2,_0x2d7219){var _0x2431d3=_0x8c18df;return compose()[_0xd84d('0xf')](function(_0x394ee6,_0x21ee70,_0x5d4da2){return db[_0xd84d('0x10')][_0xd84d('0x11')]({'where':{'id':0x1},'raw':!![]})[_0xd84d('0x12')](function(_0xd7bd4d){var _0x2533ac=getValueFromLicense(_0x224cf7,_0xd7bd4d);return _0x2533ac?_0x2533ac:_0x2431d3;})['then'](function(_0x4e0ec0){_0x2431d3=_0x4e0ec0;return _0x2e4bc2[_0xd84d('0x13')](_0x2d7219);})[_0xd84d('0x12')](function(_0x2a581e){if(_0x2a581e>=_0x2431d3){return _0x21ee70[_0xd84d('0x14')](0x193)[_0xd84d('0x15')]({'message':util[_0xd84d('0x16')]('Maximum\x20%s\x20limit\x20have\x20been\x20reached',_0x224cf7)});}_0x5d4da2();})['catch'](function(_0x352602){_0x5d4da2(_0x352602);});});}function isUserLimit(){return isLimit(_0xd84d('0x17'),0x1,db[_0xd84d('0x18')],{'where':{'$or':[{'role':_0xd84d('0x19')},{'role':_0xd84d('0x1a')}]}});}exports[_0xd84d('0x1b')]=isUserLimit;