Built motion from commit (unavailable).|2.5.4
[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 _0x5e33=['split','createDecipher','format','%s:%s:%s','update','base64','utf8','use','License','findOne','then','status','catch','users','User','admin','isUserLimit','crypto','util','../../mysqldb','../../config/environment','license','data1'];(function(_0x37f627,_0x2148ec){var _0x41436f=function(_0x5e9882){while(--_0x5e9882){_0x37f627['push'](_0x37f627['shift']());}};_0x41436f(++_0x2148ec);}(_0x5e33,0x9b));var _0x35e3=function(_0x1478c6,_0x287601){_0x1478c6=_0x1478c6-0x0;var _0x5abf02=_0x5e33[_0x1478c6];return _0x5abf02;};'use strict';var crypto=require(_0x35e3('0x0'));var util=require(_0x35e3('0x1'));var compose=require('composable-middleware');var db=require(_0x35e3('0x2'))['db'];var config=require(_0x35e3('0x3'));function getValueFromLicense(_0x3735c2,_0x4b2f05){if(_0x3735c2&&_0x4b2f05){if(_0x4b2f05['data1']&&_0x4b2f05[_0x35e3('0x4')]){var _0x2e3666=_0x4b2f05[_0x35e3('0x5')];var _0x9c1afb=_0x4b2f05[_0x35e3('0x4')];var _0x34e577=_0x2e3666['split']('-')[0x4];var _0x25d1f0=_0x2e3666[_0x35e3('0x6')]('-')[0x0];var _0x532212=crypto[_0x35e3('0x7')]('aes-256-ctr',util[_0x35e3('0x8')](_0x35e3('0x9'),_0x34e577,_0x2e3666,_0x25d1f0));var _0x1c7289=_0x532212[_0x35e3('0xa')](_0x9c1afb,_0x35e3('0xb'),'utf8');_0x1c7289+=_0x532212['final'](_0x35e3('0xc'));var _0x5cf17c=JSON['parse'](_0x1c7289);return _0x5cf17c['hasOwnProperty'](_0x3735c2)?_0x5cf17c[_0x3735c2]:null;}}return null;}function isLimit(_0x3a0adc,_0xa867d2,_0x3d83df,_0x55c318){var _0x319a91=_0xa867d2;return compose()[_0x35e3('0xd')](function(_0x533e8e,_0x3fc573,_0x299563){return db[_0x35e3('0xe')][_0x35e3('0xf')]({'where':{'id':0x1},'raw':!![]})[_0x35e3('0x10')](function(_0x8690b3){var _0x2f4553=getValueFromLicense(_0x3a0adc,_0x8690b3);return _0x2f4553?_0x2f4553:_0x319a91;})[_0x35e3('0x10')](function(_0x53ede5){_0x319a91=_0x53ede5;return _0x3d83df['count'](_0x55c318);})[_0x35e3('0x10')](function(_0x891227){if(_0x891227>=_0x319a91){return _0x3fc573[_0x35e3('0x11')](0x193)['json']({'message':util['format']('Maximum\x20%s\x20limit\x20have\x20been\x20reached',_0x3a0adc)});}_0x299563();})[_0x35e3('0x12')](function(_0x4e40ed){_0x299563(_0x4e40ed);});});}function isUserLimit(){return isLimit(_0x35e3('0x13'),0x1,db[_0x35e3('0x14')],{'where':{'$or':[{'role':_0x35e3('0x15')},{'role':'user'}]}});}exports[_0x35e3('0x16')]=isUserLimit;