Built motion from commit (unavailable).|2.4.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 _0x72a1=['util','../../mysqldb','data1','split','createDecipher','format','update','base64','final','utf8','parse','hasOwnProperty','findOne','then','count','json','Maximum\x20%s\x20limit\x20have\x20been\x20reached','users','User','admin','user','isUserLimit'];(function(_0x2d7f0e,_0x3e6fbd){var _0x110b07=function(_0x557b00){while(--_0x557b00){_0x2d7f0e['push'](_0x2d7f0e['shift']());}};_0x110b07(++_0x3e6fbd);}(_0x72a1,0x1ce));var _0x172a=function(_0x700c0e,_0x500a28){_0x700c0e=_0x700c0e-0x0;var _0x2a4ff9=_0x72a1[_0x700c0e];return _0x2a4ff9;};'use strict';var crypto=require('crypto');var util=require(_0x172a('0x0'));var compose=require('composable-middleware');var db=require(_0x172a('0x1'))['db'];var config=require('../../config/environment');function getValueFromLicense(_0x2c63c1,_0x2c3e86){if(_0x2c63c1&&_0x2c3e86){if(_0x2c3e86[_0x172a('0x2')]&&_0x2c3e86['license']){var _0x3598a9=_0x2c3e86['data1'];var _0x189579=_0x2c3e86['license'];var _0x13724a=_0x3598a9['split']('-')[0x4];var _0x15e050=_0x3598a9[_0x172a('0x3')]('-')[0x0];var _0x1164c1=crypto[_0x172a('0x4')]('aes-256-ctr',util[_0x172a('0x5')]('%s:%s:%s',_0x13724a,_0x3598a9,_0x15e050));var _0x3203a6=_0x1164c1[_0x172a('0x6')](_0x189579,_0x172a('0x7'),'utf8');_0x3203a6+=_0x1164c1[_0x172a('0x8')](_0x172a('0x9'));var _0x263da6=JSON[_0x172a('0xa')](_0x3203a6);return _0x263da6[_0x172a('0xb')](_0x2c63c1)?_0x263da6[_0x2c63c1]:null;}}return null;}function isLimit(_0x48e875,_0x301315,_0x3e3a6f,_0x3936f9){var _0x901ebc=_0x301315;return compose()['use'](function(_0x24fe54,_0x181988,_0xbea95b){return db['License'][_0x172a('0xc')]({'where':{'id':0x1},'raw':!![]})[_0x172a('0xd')](function(_0x570fa8){var _0x32f7a8=getValueFromLicense(_0x48e875,_0x570fa8);return _0x32f7a8?_0x32f7a8:_0x901ebc;})['then'](function(_0x44661f){_0x901ebc=_0x44661f;return _0x3e3a6f[_0x172a('0xe')](_0x3936f9);})['then'](function(_0x3823fa){if(_0x3823fa>=_0x901ebc){return _0x181988['status'](0x193)[_0x172a('0xf')]({'message':util[_0x172a('0x5')](_0x172a('0x10'),_0x48e875)});}_0xbea95b();})['catch'](function(_0x159f29){_0xbea95b(_0x159f29);});});}function isUserLimit(){return isLimit(_0x172a('0x11'),0x1,db[_0x172a('0x12')],{'where':{'$or':[{'role':_0x172a('0x13')},{'role':_0x172a('0x14')}]}});}exports[_0x172a('0x15')]=isUserLimit;