Built motion from commit 5ad77b03.|2.6.3
[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 _0x7cbf=['then','count','status','json','Maximum\x20%s\x20limit\x20have\x20been\x20reached','User','user','isUserLimit','crypto','util','composable-middleware','license','data1','split','aes-256-ctr','format','%s:%s:%s','update','base64','utf8','final','parse','hasOwnProperty','use','License','findOne'];(function(_0x228c19,_0x3bc38e){var _0x1b11bc=function(_0x5bb1b0){while(--_0x5bb1b0){_0x228c19['push'](_0x228c19['shift']());}};_0x1b11bc(++_0x3bc38e);}(_0x7cbf,0xbe));var _0xf7cb=function(_0x2456cf,_0x47e2c){_0x2456cf=_0x2456cf-0x0;var _0x1b6013=_0x7cbf[_0x2456cf];return _0x1b6013;};'use strict';var crypto=require(_0xf7cb('0x0'));var util=require(_0xf7cb('0x1'));var compose=require(_0xf7cb('0x2'));var db=require('../../mysqldb')['db'];var config=require('../../config/environment');function getValueFromLicense(_0x247c5d,_0x4ca399){if(_0x247c5d&&_0x4ca399){if(_0x4ca399['data1']&&_0x4ca399[_0xf7cb('0x3')]){var _0x99d03c=_0x4ca399[_0xf7cb('0x4')];var _0x217600=_0x4ca399[_0xf7cb('0x3')];var _0x2eb4f5=_0x99d03c[_0xf7cb('0x5')]('-')[0x4];var _0x489d8b=_0x99d03c[_0xf7cb('0x5')]('-')[0x0];var _0x5cb697=crypto['createDecipher'](_0xf7cb('0x6'),util[_0xf7cb('0x7')](_0xf7cb('0x8'),_0x2eb4f5,_0x99d03c,_0x489d8b));var _0xbb4ae7=_0x5cb697[_0xf7cb('0x9')](_0x217600,_0xf7cb('0xa'),_0xf7cb('0xb'));_0xbb4ae7+=_0x5cb697[_0xf7cb('0xc')](_0xf7cb('0xb'));var _0x3fbe44=JSON[_0xf7cb('0xd')](_0xbb4ae7);return _0x3fbe44[_0xf7cb('0xe')](_0x247c5d)?_0x3fbe44[_0x247c5d]:null;}}return null;}function isLimit(_0x11c30f,_0x3b6182,_0x210a82,_0x34049c){var _0x41c751=_0x3b6182;return compose()[_0xf7cb('0xf')](function(_0x5667a3,_0x1b13fe,_0x2a4e3a){return db[_0xf7cb('0x10')][_0xf7cb('0x11')]({'where':{'id':0x1},'raw':!![]})[_0xf7cb('0x12')](function(_0x39aa27){var _0x4ada14=getValueFromLicense(_0x11c30f,_0x39aa27);return _0x4ada14?_0x4ada14:_0x41c751;})['then'](function(_0x446509){_0x41c751=_0x446509;return _0x210a82[_0xf7cb('0x13')](_0x34049c);})['then'](function(_0x578b84){if(_0x578b84>=_0x41c751){return _0x1b13fe[_0xf7cb('0x14')](0x193)[_0xf7cb('0x15')]({'message':util[_0xf7cb('0x7')](_0xf7cb('0x16'),_0x11c30f)});}_0x2a4e3a();})['catch'](function(_0x24f361){_0x2a4e3a(_0x24f361);});});}function isUserLimit(){return isLimit('users',0x1,db[_0xf7cb('0x17')],{'where':{'$or':[{'role':'admin'},{'role':_0xf7cb('0x18')}]}});}exports[_0xf7cb('0x19')]=isUserLimit;