Built motion from commit (unavailable).|2.5.13
[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 _0xf4d8=['format','%s:%s:%s','update','base64','final','utf8','hasOwnProperty','use','License','findOne','then','status','json','users','User','admin','user','isUserLimit','crypto','util','../../mysqldb','data1','split','createDecipher'];(function(_0x549928,_0x363b7a){var _0x941e27=function(_0x280fe6){while(--_0x280fe6){_0x549928['push'](_0x549928['shift']());}};_0x941e27(++_0x363b7a);}(_0xf4d8,0x132));var _0x8f4d=function(_0x151f58,_0x56c0b9){_0x151f58=_0x151f58-0x0;var _0x105143=_0xf4d8[_0x151f58];return _0x105143;};'use strict';var crypto=require(_0x8f4d('0x0'));var util=require(_0x8f4d('0x1'));var compose=require('composable-middleware');var db=require(_0x8f4d('0x2'))['db'];var config=require('../../config/environment');function getValueFromLicense(_0x34b999,_0x4ca648){if(_0x34b999&&_0x4ca648){if(_0x4ca648[_0x8f4d('0x3')]&&_0x4ca648['license']){var _0x3a479c=_0x4ca648['data1'];var _0x4976e7=_0x4ca648['license'];var _0x1664c5=_0x3a479c['split']('-')[0x4];var _0x389985=_0x3a479c[_0x8f4d('0x4')]('-')[0x0];var _0x2f6c69=crypto[_0x8f4d('0x5')]('aes-256-ctr',util[_0x8f4d('0x6')](_0x8f4d('0x7'),_0x1664c5,_0x3a479c,_0x389985));var _0x1ddc0c=_0x2f6c69[_0x8f4d('0x8')](_0x4976e7,_0x8f4d('0x9'),'utf8');_0x1ddc0c+=_0x2f6c69[_0x8f4d('0xa')](_0x8f4d('0xb'));var _0x1b8557=JSON['parse'](_0x1ddc0c);return _0x1b8557[_0x8f4d('0xc')](_0x34b999)?_0x1b8557[_0x34b999]:null;}}return null;}function isLimit(_0x5da196,_0x3384fa,_0x118258,_0x2fb06d){var _0x4422e7=_0x3384fa;return compose()[_0x8f4d('0xd')](function(_0x4ee49d,_0xcf167d,_0x2c8615){return db[_0x8f4d('0xe')][_0x8f4d('0xf')]({'where':{'id':0x1},'raw':!![]})[_0x8f4d('0x10')](function(_0x560900){var _0x4411e7=getValueFromLicense(_0x5da196,_0x560900);return _0x4411e7?_0x4411e7:_0x4422e7;})['then'](function(_0x22f3c4){_0x4422e7=_0x22f3c4;return _0x118258['count'](_0x2fb06d);})[_0x8f4d('0x10')](function(_0x58b21f){if(_0x58b21f>=_0x4422e7){return _0xcf167d[_0x8f4d('0x11')](0x193)[_0x8f4d('0x12')]({'message':util[_0x8f4d('0x6')]('Maximum\x20%s\x20limit\x20have\x20been\x20reached',_0x5da196)});}_0x2c8615();})['catch'](function(_0x2676d0){_0x2c8615(_0x2676d0);});});}function isUserLimit(){return isLimit(_0x8f4d('0x13'),0x1,db[_0x8f4d('0x14')],{'where':{'$or':[{'role':_0x8f4d('0x15')},{'role':_0x8f4d('0x16')}]}});}exports[_0x8f4d('0x17')]=isUserLimit;