a177ca4e850a999bc58426131d8aeb4b77d6d7ae
[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 _0x1e16=['format','%s:%s:%s','base64','final','utf8','parse','use','License','then','status','json','catch','users','User','admin','user','isUserLimit','crypto','composable-middleware','data1','license','split','createDecipher','aes-256-ctr'];(function(_0x1c5224,_0x53396d){var _0x44b338=function(_0x4a623a){while(--_0x4a623a){_0x1c5224['push'](_0x1c5224['shift']());}};_0x44b338(++_0x53396d);}(_0x1e16,0x1d9));var _0x61e1=function(_0x19d350,_0x3c843f){_0x19d350=_0x19d350-0x0;var _0x3bfc8d=_0x1e16[_0x19d350];return _0x3bfc8d;};'use strict';var crypto=require(_0x61e1('0x0'));var util=require('util');var compose=require(_0x61e1('0x1'));var db=require('../../mysqldb')['db'];var config=require('../../config/environment');function getValueFromLicense(_0x5d6620,_0x295270){if(_0x5d6620&&_0x295270){if(_0x295270[_0x61e1('0x2')]&&_0x295270['license']){var _0x51c2c8=_0x295270[_0x61e1('0x2')];var _0x3b2048=_0x295270[_0x61e1('0x3')];var _0x33d892=_0x51c2c8[_0x61e1('0x4')]('-')[0x4];var _0x10b8f1=_0x51c2c8[_0x61e1('0x4')]('-')[0x0];var _0x6edd39=crypto[_0x61e1('0x5')](_0x61e1('0x6'),util[_0x61e1('0x7')](_0x61e1('0x8'),_0x33d892,_0x51c2c8,_0x10b8f1));var _0x5b52a6=_0x6edd39['update'](_0x3b2048,_0x61e1('0x9'),'utf8');_0x5b52a6+=_0x6edd39[_0x61e1('0xa')](_0x61e1('0xb'));var _0x2c3dbd=JSON[_0x61e1('0xc')](_0x5b52a6);return _0x2c3dbd['hasOwnProperty'](_0x5d6620)?_0x2c3dbd[_0x5d6620]:null;}}return null;}function isLimit(_0x4d9219,_0x2930a0,_0x532e3c,_0x5deeff){var _0x1fa779=_0x2930a0;return compose()[_0x61e1('0xd')](function(_0x383478,_0x52c5f9,_0x5aa210){return db[_0x61e1('0xe')]['findOne']({'where':{'id':0x1},'raw':!![]})['then'](function(_0x466f4c){var _0x1b94c0=getValueFromLicense(_0x4d9219,_0x466f4c);return _0x1b94c0?_0x1b94c0:_0x1fa779;})[_0x61e1('0xf')](function(_0x17ad10){_0x1fa779=_0x17ad10;return _0x532e3c['count'](_0x5deeff);})[_0x61e1('0xf')](function(_0x114538){if(_0x114538>=_0x1fa779){return _0x52c5f9[_0x61e1('0x10')](0x193)[_0x61e1('0x11')]({'message':util[_0x61e1('0x7')]('Maximum\x20%s\x20limit\x20have\x20been\x20reached',_0x4d9219)});}_0x5aa210();})[_0x61e1('0x12')](function(_0x496ae3){_0x5aa210(_0x496ae3);});});}function isUserLimit(){return isLimit(_0x61e1('0x13'),0x1,db[_0x61e1('0x14')],{'where':{'$or':[{'role':_0x61e1('0x15')},{'role':_0x61e1('0x16')}]}});}exports[_0x61e1('0x17')]=isUserLimit;