Built motion from commit ff78e754.|2.6.29
[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 _0xc477=['User','admin','user','crypto','util','license','data1','split','createDecipher','aes-256-ctr','update','base64','utf8','final','parse','hasOwnProperty','use','License','findOne','then','count','status','json','format','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch'];(function(_0x371cce,_0x90e874){var _0x461395=function(_0x1860b8){while(--_0x1860b8){_0x371cce['push'](_0x371cce['shift']());}};_0x461395(++_0x90e874);}(_0xc477,0x1a3));var _0x7c47=function(_0x725a4c,_0x102507){_0x725a4c=_0x725a4c-0x0;var _0x37b2cc=_0xc477[_0x725a4c];return _0x37b2cc;};'use strict';var crypto=require(_0x7c47('0x0'));var util=require(_0x7c47('0x1'));var compose=require('composable-middleware');var db=require('../../mysqldb')['db'];var config=require('../../config/environment');function getValueFromLicense(_0x528e4e,_0x2eb991){if(_0x528e4e&&_0x2eb991){if(_0x2eb991['data1']&&_0x2eb991[_0x7c47('0x2')]){var _0x4a1d92=_0x2eb991[_0x7c47('0x3')];var _0x29977b=_0x2eb991['license'];var _0x32d7a9=_0x4a1d92[_0x7c47('0x4')]('-')[0x4];var _0x1343f0=_0x4a1d92['split']('-')[0x0];var _0x1c9a26=crypto[_0x7c47('0x5')](_0x7c47('0x6'),util['format']('%s:%s:%s',_0x32d7a9,_0x4a1d92,_0x1343f0));var _0x4064c3=_0x1c9a26[_0x7c47('0x7')](_0x29977b,_0x7c47('0x8'),_0x7c47('0x9'));_0x4064c3+=_0x1c9a26[_0x7c47('0xa')](_0x7c47('0x9'));var _0x48921a=JSON[_0x7c47('0xb')](_0x4064c3);return _0x48921a[_0x7c47('0xc')](_0x528e4e)?_0x48921a[_0x528e4e]:null;}}return null;}function isLimit(_0x437bef,_0x157289,_0x3f504a,_0xa49a1){var _0x3ec610=_0x157289;return compose()[_0x7c47('0xd')](function(_0x637245,_0x289b2d,_0x46e8e2){return db[_0x7c47('0xe')][_0x7c47('0xf')]({'where':{'id':0x1},'raw':!![]})[_0x7c47('0x10')](function(_0x48d71e){var _0x5298fb=getValueFromLicense(_0x437bef,_0x48d71e);return _0x5298fb?_0x5298fb:_0x3ec610;})[_0x7c47('0x10')](function(_0x8447c5){_0x3ec610=_0x8447c5;return _0x3f504a[_0x7c47('0x11')](_0xa49a1);})[_0x7c47('0x10')](function(_0xd8062c){if(_0xd8062c>=_0x3ec610){return _0x289b2d[_0x7c47('0x12')](0x193)[_0x7c47('0x13')]({'message':util[_0x7c47('0x14')](_0x7c47('0x15'),_0x437bef)});}_0x46e8e2();})[_0x7c47('0x16')](function(_0x3eb6bf){_0x46e8e2(_0x3eb6bf);});});}function isUserLimit(){return isLimit('users',0x1,db[_0x7c47('0x17')],{'where':{'$or':[{'role':_0x7c47('0x18')},{'role':_0x7c47('0x19')}]}});}exports['isUserLimit']=isUserLimit;