Built motion from commit 775e2a94.|2.6.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 _0x23c4=['base64','final','utf8','parse','use','findOne','then','count','status','json','format','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','users','User','admin','user','crypto','composable-middleware','data1','license','split','createDecipher','aes-256-ctr','%s:%s:%s','update'];(function(_0x249a3e,_0x36a93a){var _0x4f771c=function(_0x5be32c){while(--_0x5be32c){_0x249a3e['push'](_0x249a3e['shift']());}};_0x4f771c(++_0x36a93a);}(_0x23c4,0x163));var _0x423c=function(_0x8b247d,_0x9401a9){_0x8b247d=_0x8b247d-0x0;var _0x4e10a3=_0x23c4[_0x8b247d];return _0x4e10a3;};'use strict';var crypto=require(_0x423c('0x0'));var util=require('util');var compose=require(_0x423c('0x1'));var db=require('../../mysqldb')['db'];var config=require('../../config/environment');function getValueFromLicense(_0x441399,_0x529192){if(_0x441399&&_0x529192){if(_0x529192[_0x423c('0x2')]&&_0x529192[_0x423c('0x3')]){var _0x22c636=_0x529192[_0x423c('0x2')];var _0xe93090=_0x529192[_0x423c('0x3')];var _0x22fe6a=_0x22c636[_0x423c('0x4')]('-')[0x4];var _0x605578=_0x22c636['split']('-')[0x0];var _0x2e0ecc=crypto[_0x423c('0x5')](_0x423c('0x6'),util['format'](_0x423c('0x7'),_0x22fe6a,_0x22c636,_0x605578));var _0x5e2da7=_0x2e0ecc[_0x423c('0x8')](_0xe93090,_0x423c('0x9'),'utf8');_0x5e2da7+=_0x2e0ecc[_0x423c('0xa')](_0x423c('0xb'));var _0x65b789=JSON[_0x423c('0xc')](_0x5e2da7);return _0x65b789['hasOwnProperty'](_0x441399)?_0x65b789[_0x441399]:null;}}return null;}function isLimit(_0x275115,_0x115969,_0x422e48,_0x458a2d){var _0xd4807f=_0x115969;return compose()[_0x423c('0xd')](function(_0x158cd1,_0x29679a,_0x420f88){return db['License'][_0x423c('0xe')]({'where':{'id':0x1},'raw':!![]})[_0x423c('0xf')](function(_0x2e8098){var _0x3ebe80=getValueFromLicense(_0x275115,_0x2e8098);return _0x3ebe80?_0x3ebe80:_0xd4807f;})[_0x423c('0xf')](function(_0x2640e7){_0xd4807f=_0x2640e7;return _0x422e48[_0x423c('0x10')](_0x458a2d);})[_0x423c('0xf')](function(_0x289ba9){if(_0x289ba9>=_0xd4807f){return _0x29679a[_0x423c('0x11')](0x193)[_0x423c('0x12')]({'message':util[_0x423c('0x13')](_0x423c('0x14'),_0x275115)});}_0x420f88();})[_0x423c('0x15')](function(_0x1c571e){_0x420f88(_0x1c571e);});});}function isUserLimit(){return isLimit(_0x423c('0x16'),0x1,db[_0x423c('0x17')],{'where':{'$or':[{'role':_0x423c('0x18')},{'role':_0x423c('0x19')}]}});}exports['isUserLimit']=isUserLimit;