Built motion from commit (unavailable).|2.5.4
[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 _0x037c=['createDecipher','format','%s:%s:%s','update','base64','utf8','final','parse','hasOwnProperty','use','License','findOne','then','count','json','users','User','user','isUserLimit','crypto','util','../../mysqldb','../../config/environment','data1','license','split'];(function(_0x40b8c4,_0x19b74f){var _0x15391f=function(_0x270009){while(--_0x270009){_0x40b8c4['push'](_0x40b8c4['shift']());}};_0x15391f(++_0x19b74f);}(_0x037c,0x95));var _0xc037=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x037c[_0x3dd15e];return _0x231fd0;};'use strict';var crypto=require(_0xc037('0x0'));var util=require(_0xc037('0x1'));var compose=require('composable-middleware');var db=require(_0xc037('0x2'))['db'];var config=require(_0xc037('0x3'));function getValueFromLicense(_0x4c55b5,_0x478fe){if(_0x4c55b5&&_0x478fe){if(_0x478fe[_0xc037('0x4')]&&_0x478fe['license']){var _0x28eeef=_0x478fe[_0xc037('0x4')];var _0x2e8966=_0x478fe[_0xc037('0x5')];var _0x2091f6=_0x28eeef['split']('-')[0x4];var _0x89d84=_0x28eeef[_0xc037('0x6')]('-')[0x0];var _0x6f7729=crypto[_0xc037('0x7')]('aes-256-ctr',util[_0xc037('0x8')](_0xc037('0x9'),_0x2091f6,_0x28eeef,_0x89d84));var _0x2ddcd6=_0x6f7729[_0xc037('0xa')](_0x2e8966,_0xc037('0xb'),_0xc037('0xc'));_0x2ddcd6+=_0x6f7729[_0xc037('0xd')]('utf8');var _0xe7b7e9=JSON[_0xc037('0xe')](_0x2ddcd6);return _0xe7b7e9[_0xc037('0xf')](_0x4c55b5)?_0xe7b7e9[_0x4c55b5]:null;}}return null;}function isLimit(_0x4317bf,_0x157208,_0x5d9090,_0x4c00ee){var _0x20dc32=_0x157208;return compose()[_0xc037('0x10')](function(_0x43ef33,_0x29b36b,_0x53d11f){return db[_0xc037('0x11')][_0xc037('0x12')]({'where':{'id':0x1},'raw':!![]})[_0xc037('0x13')](function(_0x1e07d6){var _0x5d6b4d=getValueFromLicense(_0x4317bf,_0x1e07d6);return _0x5d6b4d?_0x5d6b4d:_0x20dc32;})[_0xc037('0x13')](function(_0x5eb855){_0x20dc32=_0x5eb855;return _0x5d9090[_0xc037('0x14')](_0x4c00ee);})['then'](function(_0x10c85d){if(_0x10c85d>=_0x20dc32){return _0x29b36b['status'](0x193)[_0xc037('0x15')]({'message':util['format']('Maximum\x20%s\x20limit\x20have\x20been\x20reached',_0x4317bf)});}_0x53d11f();})['catch'](function(_0x4bfffc){_0x53d11f(_0x4bfffc);});});}function isUserLimit(){return isLimit(_0xc037('0x16'),0x1,db[_0xc037('0x17')],{'where':{'$or':[{'role':'admin'},{'role':_0xc037('0x18')}]}});}exports[_0xc037('0x19')]=isUserLimit;