Built motion from commit f7863d46.|2.5.41
[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 _0x2c0e=['then','count','status','json','isUserLimit','crypto','util','composable-middleware','../../config/environment','data1','license','split','format','%s:%s:%s','update','utf8','final','parse','hasOwnProperty','use','License','findOne'];(function(_0x3effe3,_0x388c5d){var _0x3d1e83=function(_0x17acf3){while(--_0x17acf3){_0x3effe3['push'](_0x3effe3['shift']());}};_0x3d1e83(++_0x388c5d);}(_0x2c0e,0x9f));var _0xe2c0=function(_0x5e9a69,_0x40c0ec){_0x5e9a69=_0x5e9a69-0x0;var _0x5979c8=_0x2c0e[_0x5e9a69];return _0x5979c8;};'use strict';var crypto=require(_0xe2c0('0x0'));var util=require(_0xe2c0('0x1'));var compose=require(_0xe2c0('0x2'));var db=require('../../mysqldb')['db'];var config=require(_0xe2c0('0x3'));function getValueFromLicense(_0x400aa5,_0x1f4a03){if(_0x400aa5&&_0x1f4a03){if(_0x1f4a03[_0xe2c0('0x4')]&&_0x1f4a03[_0xe2c0('0x5')]){var _0x44b23f=_0x1f4a03[_0xe2c0('0x4')];var _0x5ce3b0=_0x1f4a03[_0xe2c0('0x5')];var _0x1ed8db=_0x44b23f[_0xe2c0('0x6')]('-')[0x4];var _0x5d4e45=_0x44b23f['split']('-')[0x0];var _0x3768dc=crypto['createDecipher']('aes-256-ctr',util[_0xe2c0('0x7')](_0xe2c0('0x8'),_0x1ed8db,_0x44b23f,_0x5d4e45));var _0x10af02=_0x3768dc[_0xe2c0('0x9')](_0x5ce3b0,'base64',_0xe2c0('0xa'));_0x10af02+=_0x3768dc[_0xe2c0('0xb')](_0xe2c0('0xa'));var _0x5ade01=JSON[_0xe2c0('0xc')](_0x10af02);return _0x5ade01[_0xe2c0('0xd')](_0x400aa5)?_0x5ade01[_0x400aa5]:null;}}return null;}function isLimit(_0x3ac879,_0x4f8bfa,_0x29bcef,_0x34d3a7){var _0x367f4f=_0x4f8bfa;return compose()[_0xe2c0('0xe')](function(_0x5779de,_0x407317,_0x5c1964){return db[_0xe2c0('0xf')][_0xe2c0('0x10')]({'where':{'id':0x1},'raw':!![]})[_0xe2c0('0x11')](function(_0x13d224){var _0x4ea40d=getValueFromLicense(_0x3ac879,_0x13d224);return _0x4ea40d?_0x4ea40d:_0x367f4f;})['then'](function(_0x45841e){_0x367f4f=_0x45841e;return _0x29bcef[_0xe2c0('0x12')](_0x34d3a7);})[_0xe2c0('0x11')](function(_0x3c57d6){if(_0x3c57d6>=_0x367f4f){return _0x407317[_0xe2c0('0x13')](0x193)[_0xe2c0('0x14')]({'message':util[_0xe2c0('0x7')]('Maximum\x20%s\x20limit\x20have\x20been\x20reached',_0x3ac879)});}_0x5c1964();})['catch'](function(_0x1e95f6){_0x5c1964(_0x1e95f6);});});}function isUserLimit(){return isLimit('users',0x1,db['User'],{'where':{'$or':[{'role':'admin'},{'role':'user'}]}});}exports[_0xe2c0('0x15')]=isUserLimit;