0750ff0d0dc68702b065f3ee525ba4ff998ad65d
[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 _0x9280=['format','%s:%s:%s','update','utf8','final','parse','hasOwnProperty','License','findOne','then','count','Maximum\x20%s\x20limit\x20have\x20been\x20reached','users','User','admin','user','crypto','util','composable-middleware','../../config/environment','license'];(function(_0x1f55cb,_0x381162){var _0x52c43a=function(_0x55e98c){while(--_0x55e98c){_0x1f55cb['push'](_0x1f55cb['shift']());}};_0x52c43a(++_0x381162);}(_0x9280,0x1f3));var _0x0928=function(_0x5e0a05,_0x55152b){_0x5e0a05=_0x5e0a05-0x0;var _0x2bc529=_0x9280[_0x5e0a05];return _0x2bc529;};'use strict';var crypto=require(_0x0928('0x0'));var util=require(_0x0928('0x1'));var compose=require(_0x0928('0x2'));var db=require('../../mysqldb')['db'];var config=require(_0x0928('0x3'));function getValueFromLicense(_0xbd1bb3,_0x3f29de){if(_0xbd1bb3&&_0x3f29de){if(_0x3f29de['data1']&&_0x3f29de[_0x0928('0x4')]){var _0xf8ad2=_0x3f29de['data1'];var _0x3acd03=_0x3f29de[_0x0928('0x4')];var _0x1481de=_0xf8ad2['split']('-')[0x4];var _0x236865=_0xf8ad2['split']('-')[0x0];var _0x19c8c1=crypto['createDecipher']('aes-256-ctr',util[_0x0928('0x5')](_0x0928('0x6'),_0x1481de,_0xf8ad2,_0x236865));var _0x5453dd=_0x19c8c1[_0x0928('0x7')](_0x3acd03,'base64',_0x0928('0x8'));_0x5453dd+=_0x19c8c1[_0x0928('0x9')](_0x0928('0x8'));var _0xb055b4=JSON[_0x0928('0xa')](_0x5453dd);return _0xb055b4[_0x0928('0xb')](_0xbd1bb3)?_0xb055b4[_0xbd1bb3]:null;}}return null;}function isLimit(_0x3cdd71,_0x45c47b,_0x3a7986,_0x8690a0){var _0x19f303=_0x45c47b;return compose()['use'](function(_0x331fea,_0x453119,_0x15271e){return db[_0x0928('0xc')][_0x0928('0xd')]({'where':{'id':0x1},'raw':!![]})['then'](function(_0x3755ea){var _0x352f48=getValueFromLicense(_0x3cdd71,_0x3755ea);return _0x352f48?_0x352f48:_0x19f303;})[_0x0928('0xe')](function(_0x3d3f11){_0x19f303=_0x3d3f11;return _0x3a7986[_0x0928('0xf')](_0x8690a0);})['then'](function(_0x44e105){if(_0x44e105>=_0x19f303){return _0x453119['status'](0x193)['json']({'message':util[_0x0928('0x5')](_0x0928('0x10'),_0x3cdd71)});}_0x15271e();})['catch'](function(_0x18eff0){_0x15271e(_0x18eff0);});});}function isUserLimit(){return isLimit(_0x0928('0x11'),0x1,db[_0x0928('0x12')],{'where':{'$or':[{'role':_0x0928('0x13')},{'role':_0x0928('0x14')}]}});}exports['isUserLimit']=isUserLimit;