Built motion from commit 7158bc59.|2.5.42
[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 _0xde75=['crypto','util','composable-middleware','../../mysqldb','../../config/environment','data1','license','split','createDecipher','format','update','base64','utf8','parse','hasOwnProperty','use','License','findOne','then','count','Maximum\x20%s\x20limit\x20have\x20been\x20reached','User','admin','user','isUserLimit'];(function(_0x1301aa,_0x4da5c4){var _0x5146a1=function(_0x417cd1){while(--_0x417cd1){_0x1301aa['push'](_0x1301aa['shift']());}};_0x5146a1(++_0x4da5c4);}(_0xde75,0x64));var _0x5de7=function(_0x2b1867,_0x30b683){_0x2b1867=_0x2b1867-0x0;var _0x519519=_0xde75[_0x2b1867];return _0x519519;};'use strict';var crypto=require(_0x5de7('0x0'));var util=require(_0x5de7('0x1'));var compose=require(_0x5de7('0x2'));var db=require(_0x5de7('0x3'))['db'];var config=require(_0x5de7('0x4'));function getValueFromLicense(_0x1b6bfb,_0x5c6109){if(_0x1b6bfb&&_0x5c6109){if(_0x5c6109[_0x5de7('0x5')]&&_0x5c6109[_0x5de7('0x6')]){var _0xdd4c20=_0x5c6109[_0x5de7('0x5')];var _0x21b0aa=_0x5c6109[_0x5de7('0x6')];var _0x31adbf=_0xdd4c20[_0x5de7('0x7')]('-')[0x4];var _0x3f19e6=_0xdd4c20[_0x5de7('0x7')]('-')[0x0];var _0x19ac44=crypto[_0x5de7('0x8')]('aes-256-ctr',util[_0x5de7('0x9')]('%s:%s:%s',_0x31adbf,_0xdd4c20,_0x3f19e6));var _0x514762=_0x19ac44[_0x5de7('0xa')](_0x21b0aa,_0x5de7('0xb'),_0x5de7('0xc'));_0x514762+=_0x19ac44['final'](_0x5de7('0xc'));var _0x3c9fa5=JSON[_0x5de7('0xd')](_0x514762);return _0x3c9fa5[_0x5de7('0xe')](_0x1b6bfb)?_0x3c9fa5[_0x1b6bfb]:null;}}return null;}function isLimit(_0x4d5a36,_0x3e41d6,_0x5d9f2e,_0x47511c){var _0x1c4622=_0x3e41d6;return compose()[_0x5de7('0xf')](function(_0x2d5d10,_0x256092,_0x405fd2){return db[_0x5de7('0x10')][_0x5de7('0x11')]({'where':{'id':0x1},'raw':!![]})[_0x5de7('0x12')](function(_0x18eb36){var _0x1689c1=getValueFromLicense(_0x4d5a36,_0x18eb36);return _0x1689c1?_0x1689c1:_0x1c4622;})[_0x5de7('0x12')](function(_0x2ec7d2){_0x1c4622=_0x2ec7d2;return _0x5d9f2e[_0x5de7('0x13')](_0x47511c);})[_0x5de7('0x12')](function(_0x52d837){if(_0x52d837>=_0x1c4622){return _0x256092['status'](0x193)['json']({'message':util[_0x5de7('0x9')](_0x5de7('0x14'),_0x4d5a36)});}_0x405fd2();})['catch'](function(_0x299baa){_0x405fd2(_0x299baa);});});}function isUserLimit(){return isLimit('users',0x1,db[_0x5de7('0x15')],{'where':{'$or':[{'role':_0x5de7('0x16')},{'role':_0x5de7('0x17')}]}});}exports[_0x5de7('0x18')]=isUserLimit;