Built motion from commit 14588770.|2.5.38
[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 _0xea31=['json','catch','User','isUserLimit','crypto','composable-middleware','data1','license','split','createDecipher','aes-256-ctr','format','%s:%s:%s','update','base64','utf8','final','hasOwnProperty','use','License','findOne','then'];(function(_0x524db7,_0x10031b){var _0x466ef5=function(_0x223aef){while(--_0x223aef){_0x524db7['push'](_0x524db7['shift']());}};_0x466ef5(++_0x10031b);}(_0xea31,0x164));var _0x1ea3=function(_0x59db66,_0x47dbb9){_0x59db66=_0x59db66-0x0;var _0x3cda2b=_0xea31[_0x59db66];return _0x3cda2b;};'use strict';var crypto=require(_0x1ea3('0x0'));var util=require('util');var compose=require(_0x1ea3('0x1'));var db=require('../../mysqldb')['db'];var config=require('../../config/environment');function getValueFromLicense(_0x5ad686,_0x82d1c0){if(_0x5ad686&&_0x82d1c0){if(_0x82d1c0['data1']&&_0x82d1c0['license']){var _0x32c995=_0x82d1c0[_0x1ea3('0x2')];var _0x15204e=_0x82d1c0[_0x1ea3('0x3')];var _0x5985c3=_0x32c995['split']('-')[0x4];var _0x53fe96=_0x32c995[_0x1ea3('0x4')]('-')[0x0];var _0x48471d=crypto[_0x1ea3('0x5')](_0x1ea3('0x6'),util[_0x1ea3('0x7')](_0x1ea3('0x8'),_0x5985c3,_0x32c995,_0x53fe96));var _0x3cda94=_0x48471d[_0x1ea3('0x9')](_0x15204e,_0x1ea3('0xa'),_0x1ea3('0xb'));_0x3cda94+=_0x48471d[_0x1ea3('0xc')]('utf8');var _0x128010=JSON['parse'](_0x3cda94);return _0x128010[_0x1ea3('0xd')](_0x5ad686)?_0x128010[_0x5ad686]:null;}}return null;}function isLimit(_0x195e4c,_0x2885b0,_0x2b5944,_0x1e8a44){var _0x3e33f2=_0x2885b0;return compose()[_0x1ea3('0xe')](function(_0x25fa05,_0x2c28eb,_0x50b4c7){return db[_0x1ea3('0xf')][_0x1ea3('0x10')]({'where':{'id':0x1},'raw':!![]})[_0x1ea3('0x11')](function(_0x1d7639){var _0x547158=getValueFromLicense(_0x195e4c,_0x1d7639);return _0x547158?_0x547158:_0x3e33f2;})[_0x1ea3('0x11')](function(_0x26d310){_0x3e33f2=_0x26d310;return _0x2b5944['count'](_0x1e8a44);})['then'](function(_0x426847){if(_0x426847>=_0x3e33f2){return _0x2c28eb['status'](0x193)[_0x1ea3('0x12')]({'message':util[_0x1ea3('0x7')]('Maximum\x20%s\x20limit\x20have\x20been\x20reached',_0x195e4c)});}_0x50b4c7();})[_0x1ea3('0x13')](function(_0x12240d){_0x50b4c7(_0x12240d);});});}function isUserLimit(){return isLimit('users',0x1,db[_0x1ea3('0x14')],{'where':{'$or':[{'role':'admin'},{'role':'user'}]}});}exports[_0x1ea3('0x15')]=isUserLimit;