Built motion from commit 9c91e9f5.|2.6.29
[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 _0x05c1=['then','status','json','format','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','users','User','user','isUserLimit','crypto','util','composable-middleware','../../mysqldb','../../config/environment','data1','license','split','createDecipher','utf8','final','parse','hasOwnProperty','License','findOne'];(function(_0x26ed77,_0x5d3145){var _0x33ef92=function(_0x1c5ec0){while(--_0x1c5ec0){_0x26ed77['push'](_0x26ed77['shift']());}};_0x33ef92(++_0x5d3145);}(_0x05c1,0x168));var _0x105c=function(_0x55c947,_0x5e20a8){_0x55c947=_0x55c947-0x0;var _0x2556b3=_0x05c1[_0x55c947];return _0x2556b3;};'use strict';var crypto=require(_0x105c('0x0'));var util=require(_0x105c('0x1'));var compose=require(_0x105c('0x2'));var db=require(_0x105c('0x3'))['db'];var config=require(_0x105c('0x4'));function getValueFromLicense(_0x50a965,_0x10d63b){if(_0x50a965&&_0x10d63b){if(_0x10d63b[_0x105c('0x5')]&&_0x10d63b[_0x105c('0x6')]){var _0x577ac0=_0x10d63b[_0x105c('0x5')];var _0x571a3b=_0x10d63b[_0x105c('0x6')];var _0x106fa6=_0x577ac0[_0x105c('0x7')]('-')[0x4];var _0x18e0b0=_0x577ac0[_0x105c('0x7')]('-')[0x0];var _0x5b43f3=crypto[_0x105c('0x8')]('aes-256-ctr',util['format']('%s:%s:%s',_0x106fa6,_0x577ac0,_0x18e0b0));var _0x3a437e=_0x5b43f3['update'](_0x571a3b,'base64',_0x105c('0x9'));_0x3a437e+=_0x5b43f3[_0x105c('0xa')](_0x105c('0x9'));var _0x454dd2=JSON[_0x105c('0xb')](_0x3a437e);return _0x454dd2[_0x105c('0xc')](_0x50a965)?_0x454dd2[_0x50a965]:null;}}return null;}function isLimit(_0x767b80,_0x1e46a9,_0x225a37,_0x47b4a6){var _0x58042a=_0x1e46a9;return compose()['use'](function(_0x2d5c97,_0x4e2090,_0x394d98){return db[_0x105c('0xd')][_0x105c('0xe')]({'where':{'id':0x1},'raw':!![]})[_0x105c('0xf')](function(_0x53dae8){var _0x4bed8e=getValueFromLicense(_0x767b80,_0x53dae8);return _0x4bed8e?_0x4bed8e:_0x58042a;})[_0x105c('0xf')](function(_0x2c0454){_0x58042a=_0x2c0454;return _0x225a37['count'](_0x47b4a6);})[_0x105c('0xf')](function(_0x2f26f9){if(_0x2f26f9>=_0x58042a){return _0x4e2090[_0x105c('0x10')](0x193)[_0x105c('0x11')]({'message':util[_0x105c('0x12')](_0x105c('0x13'),_0x767b80)});}_0x394d98();})[_0x105c('0x14')](function(_0x339600){_0x394d98(_0x339600);});});}function isUserLimit(){return isLimit(_0x105c('0x15'),0x1,db[_0x105c('0x16')],{'where':{'$or':[{'role':'admin'},{'role':_0x105c('0x17')}]}});}exports[_0x105c('0x18')]=isUserLimit;