Built motion from commit (unavailable).|2.5.22
[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 _0x1319=['then','count','status','json','catch','User','admin','user','crypto','util','../../config/environment','data1','license','split','createDecipher','aes-256-ctr','format','%s:%s:%s','update','base64','utf8','final','parse','hasOwnProperty'];(function(_0x551bc4,_0x330316){var _0x5af907=function(_0x41d277){while(--_0x41d277){_0x551bc4['push'](_0x551bc4['shift']());}};_0x5af907(++_0x330316);}(_0x1319,0x1a0));var _0x9131=function(_0x26d353,_0x1623f9){_0x26d353=_0x26d353-0x0;var _0x40847a=_0x1319[_0x26d353];return _0x40847a;};'use strict';var crypto=require(_0x9131('0x0'));var util=require(_0x9131('0x1'));var compose=require('composable-middleware');var db=require('../../mysqldb')['db'];var config=require(_0x9131('0x2'));function getValueFromLicense(_0xb735d0,_0x18dbe9){if(_0xb735d0&&_0x18dbe9){if(_0x18dbe9[_0x9131('0x3')]&&_0x18dbe9[_0x9131('0x4')]){var _0x5ba21c=_0x18dbe9[_0x9131('0x3')];var _0x21a034=_0x18dbe9[_0x9131('0x4')];var _0x41c493=_0x5ba21c[_0x9131('0x5')]('-')[0x4];var _0x4620dc=_0x5ba21c[_0x9131('0x5')]('-')[0x0];var _0x495586=crypto[_0x9131('0x6')](_0x9131('0x7'),util[_0x9131('0x8')](_0x9131('0x9'),_0x41c493,_0x5ba21c,_0x4620dc));var _0xda808c=_0x495586[_0x9131('0xa')](_0x21a034,_0x9131('0xb'),_0x9131('0xc'));_0xda808c+=_0x495586[_0x9131('0xd')](_0x9131('0xc'));var _0x5d9f1c=JSON[_0x9131('0xe')](_0xda808c);return _0x5d9f1c[_0x9131('0xf')](_0xb735d0)?_0x5d9f1c[_0xb735d0]:null;}}return null;}function isLimit(_0x17d11b,_0x58928f,_0x2bc02b,_0x5305be){var _0x3aaf70=_0x58928f;return compose()['use'](function(_0x445447,_0x80b1ca,_0x52af9f){return db['License']['findOne']({'where':{'id':0x1},'raw':!![]})[_0x9131('0x10')](function(_0x5d8149){var _0x36b6d8=getValueFromLicense(_0x17d11b,_0x5d8149);return _0x36b6d8?_0x36b6d8:_0x3aaf70;})[_0x9131('0x10')](function(_0xf66a92){_0x3aaf70=_0xf66a92;return _0x2bc02b[_0x9131('0x11')](_0x5305be);})[_0x9131('0x10')](function(_0x4900a9){if(_0x4900a9>=_0x3aaf70){return _0x80b1ca[_0x9131('0x12')](0x193)[_0x9131('0x13')]({'message':util[_0x9131('0x8')]('Maximum\x20%s\x20limit\x20have\x20been\x20reached',_0x17d11b)});}_0x52af9f();})[_0x9131('0x14')](function(_0x3c4821){_0x52af9f(_0x3c4821);});});}function isUserLimit(){return isLimit('users',0x1,db[_0x9131('0x15')],{'where':{'$or':[{'role':_0x9131('0x16')},{'role':_0x9131('0x17')}]}});}exports['isUserLimit']=isUserLimit;