5e748ea2c81ecec08ee2030d6ed05b211e945b75
[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 _0x0218=['count','json','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','users','User','user','isUserLimit','crypto','util','composable-middleware','../../mysqldb','../../config/environment','data1','license','split','createDecipher','aes-256-ctr','format','%s:%s:%s','update','base64','utf8','parse','use','License','findOne','then'];(function(_0x399fa6,_0x5cce5b){var _0x5320c2=function(_0x768e6a){while(--_0x768e6a){_0x399fa6['push'](_0x399fa6['shift']());}};_0x5320c2(++_0x5cce5b);}(_0x0218,0x120));var _0x8021=function(_0x41cdde,_0x4bd78c){_0x41cdde=_0x41cdde-0x0;var _0x2dec1e=_0x0218[_0x41cdde];return _0x2dec1e;};'use strict';var crypto=require(_0x8021('0x0'));var util=require(_0x8021('0x1'));var compose=require(_0x8021('0x2'));var db=require(_0x8021('0x3'))['db'];var config=require(_0x8021('0x4'));function getValueFromLicense(_0x52cb0c,_0x5544ec){if(_0x52cb0c&&_0x5544ec){if(_0x5544ec[_0x8021('0x5')]&&_0x5544ec[_0x8021('0x6')]){var _0x5e12de=_0x5544ec[_0x8021('0x5')];var _0x55681a=_0x5544ec['license'];var _0x9d599a=_0x5e12de[_0x8021('0x7')]('-')[0x4];var _0x240283=_0x5e12de['split']('-')[0x0];var _0x5a5f97=crypto[_0x8021('0x8')](_0x8021('0x9'),util[_0x8021('0xa')](_0x8021('0xb'),_0x9d599a,_0x5e12de,_0x240283));var _0x48e8e4=_0x5a5f97[_0x8021('0xc')](_0x55681a,_0x8021('0xd'),_0x8021('0xe'));_0x48e8e4+=_0x5a5f97['final'](_0x8021('0xe'));var _0x1db499=JSON[_0x8021('0xf')](_0x48e8e4);return _0x1db499['hasOwnProperty'](_0x52cb0c)?_0x1db499[_0x52cb0c]:null;}}return null;}function isLimit(_0xcf04a5,_0x3cdd03,_0x41fd1e,_0x36fe1a){var _0x24e0f9=_0x3cdd03;return compose()[_0x8021('0x10')](function(_0x1e0f1d,_0x43f587,_0x494d17){return db[_0x8021('0x11')][_0x8021('0x12')]({'where':{'id':0x1},'raw':!![]})['then'](function(_0x339ce0){var _0x527437=getValueFromLicense(_0xcf04a5,_0x339ce0);return _0x527437?_0x527437:_0x24e0f9;})[_0x8021('0x13')](function(_0x498253){_0x24e0f9=_0x498253;return _0x41fd1e[_0x8021('0x14')](_0x36fe1a);})[_0x8021('0x13')](function(_0x831508){if(_0x831508>=_0x24e0f9){return _0x43f587['status'](0x193)[_0x8021('0x15')]({'message':util[_0x8021('0xa')](_0x8021('0x16'),_0xcf04a5)});}_0x494d17();})[_0x8021('0x17')](function(_0x592664){_0x494d17(_0x592664);});});}function isUserLimit(){return isLimit(_0x8021('0x18'),0x1,db[_0x8021('0x19')],{'where':{'$or':[{'role':'admin'},{'role':_0x8021('0x1a')}]}});}exports[_0x8021('0x1b')]=isUserLimit;