f380e1ec6fc7c3ac7eaf8a6dbcf1389b2625bcae
[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 _0x60a8=['../../mysqldb','../../config/environment','data1','license','aes-256-ctr','format','%s:%s:%s','update','utf8','final','parse','findOne','then','status','json','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','User','admin','user','crypto','util','composable-middleware'];(function(_0x735297,_0x5cb20b){var _0x32c47d=function(_0x5f18cc){while(--_0x5f18cc){_0x735297['push'](_0x735297['shift']());}};_0x32c47d(++_0x5cb20b);}(_0x60a8,0xfa));var _0x860a=function(_0x52dc72,_0x3401a6){_0x52dc72=_0x52dc72-0x0;var _0x4ad3b4=_0x60a8[_0x52dc72];return _0x4ad3b4;};'use strict';var crypto=require(_0x860a('0x0'));var util=require(_0x860a('0x1'));var compose=require(_0x860a('0x2'));var db=require(_0x860a('0x3'))['db'];var config=require(_0x860a('0x4'));function getValueFromLicense(_0x5ed4bd,_0x217636){if(_0x5ed4bd&&_0x217636){if(_0x217636[_0x860a('0x5')]&&_0x217636[_0x860a('0x6')]){var _0x433719=_0x217636['data1'];var _0x2ce445=_0x217636['license'];var _0x109ee4=_0x433719['split']('-')[0x4];var _0x5eaa6a=_0x433719['split']('-')[0x0];var _0x17e69e=crypto['createDecipher'](_0x860a('0x7'),util[_0x860a('0x8')](_0x860a('0x9'),_0x109ee4,_0x433719,_0x5eaa6a));var _0x1d1fb7=_0x17e69e[_0x860a('0xa')](_0x2ce445,'base64',_0x860a('0xb'));_0x1d1fb7+=_0x17e69e[_0x860a('0xc')](_0x860a('0xb'));var _0x1efb90=JSON[_0x860a('0xd')](_0x1d1fb7);return _0x1efb90['hasOwnProperty'](_0x5ed4bd)?_0x1efb90[_0x5ed4bd]:null;}}return null;}function isLimit(_0x165c89,_0x3eb5f2,_0xe56b5,_0x5c3413){var _0x4f0793=_0x3eb5f2;return compose()['use'](function(_0xa457da,_0x1c67ce,_0x54e4c5){return db['License'][_0x860a('0xe')]({'where':{'id':0x1},'raw':!![]})[_0x860a('0xf')](function(_0x163a16){var _0xf16eb6=getValueFromLicense(_0x165c89,_0x163a16);return _0xf16eb6?_0xf16eb6:_0x4f0793;})[_0x860a('0xf')](function(_0x321854){_0x4f0793=_0x321854;return _0xe56b5['count'](_0x5c3413);})[_0x860a('0xf')](function(_0x382318){if(_0x382318>=_0x4f0793){return _0x1c67ce[_0x860a('0x10')](0x193)[_0x860a('0x11')]({'message':util[_0x860a('0x8')](_0x860a('0x12'),_0x165c89)});}_0x54e4c5();})[_0x860a('0x13')](function(_0x42ef0d){_0x54e4c5(_0x42ef0d);});});}function isUserLimit(){return isLimit('users',0x1,db[_0x860a('0x14')],{'where':{'$or':[{'role':_0x860a('0x15')},{'role':_0x860a('0x16')}]}});}exports['isUserLimit']=isUserLimit;