05386a28efd03c9ed4259fdb162fb589ea34c0c8
[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 _0x5626=['count','status','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','users','User','admin','user','isUserLimit','../../mysqldb','../../config/environment','data1','split','createDecipher','format','%s:%s:%s','base64','utf8','final','parse','License','then'];(function(_0x349ac1,_0x443243){var _0x77840a=function(_0x3e6a60){while(--_0x3e6a60){_0x349ac1['push'](_0x349ac1['shift']());}};_0x77840a(++_0x443243);}(_0x5626,0x1c1));var _0x6562=function(_0x1103d1,_0x1f980b){_0x1103d1=_0x1103d1-0x0;var _0x197597=_0x5626[_0x1103d1];return _0x197597;};'use strict';var crypto=require('crypto');var util=require('util');var compose=require('composable-middleware');var db=require(_0x6562('0x0'))['db'];var config=require(_0x6562('0x1'));function getValueFromLicense(_0x28b9ba,_0x371989){if(_0x28b9ba&&_0x371989){if(_0x371989[_0x6562('0x2')]&&_0x371989['license']){var _0x251308=_0x371989[_0x6562('0x2')];var _0x3a6e98=_0x371989['license'];var _0x35fe29=_0x251308[_0x6562('0x3')]('-')[0x4];var _0x25ddac=_0x251308[_0x6562('0x3')]('-')[0x0];var _0x5f00dc=crypto[_0x6562('0x4')]('aes-256-ctr',util[_0x6562('0x5')](_0x6562('0x6'),_0x35fe29,_0x251308,_0x25ddac));var _0x4ecc88=_0x5f00dc['update'](_0x3a6e98,_0x6562('0x7'),_0x6562('0x8'));_0x4ecc88+=_0x5f00dc[_0x6562('0x9')]('utf8');var _0x23c185=JSON[_0x6562('0xa')](_0x4ecc88);return _0x23c185['hasOwnProperty'](_0x28b9ba)?_0x23c185[_0x28b9ba]:null;}}return null;}function isLimit(_0x549b11,_0x3df2ac,_0x12a956,_0x367637){var _0x2370dc=_0x3df2ac;return compose()['use'](function(_0x551d8c,_0x18dc76,_0x5659ab){return db[_0x6562('0xb')]['findOne']({'where':{'id':0x1},'raw':!![]})[_0x6562('0xc')](function(_0x4f5ec3){var _0x4f7464=getValueFromLicense(_0x549b11,_0x4f5ec3);return _0x4f7464?_0x4f7464:_0x2370dc;})['then'](function(_0x3ae603){_0x2370dc=_0x3ae603;return _0x12a956[_0x6562('0xd')](_0x367637);})[_0x6562('0xc')](function(_0x1b70c7){if(_0x1b70c7>=_0x2370dc){return _0x18dc76[_0x6562('0xe')](0x193)['json']({'message':util[_0x6562('0x5')](_0x6562('0xf'),_0x549b11)});}_0x5659ab();})[_0x6562('0x10')](function(_0x23d402){_0x5659ab(_0x23d402);});});}function isUserLimit(){return isLimit(_0x6562('0x11'),0x1,db[_0x6562('0x12')],{'where':{'$or':[{'role':_0x6562('0x13')},{'role':_0x6562('0x14')}]}});}exports[_0x6562('0x15')]=isUserLimit;