d1dd19c57a8b4ffcd1e9c052599ea942783de610
[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 _0x02f9=['User','admin','user','isUserLimit','crypto','util','composable-middleware','../../mysqldb','../../config/environment','data1','license','split','createDecipher','aes-256-ctr','%s:%s:%s','update','base64','utf8','final','hasOwnProperty','License','findOne','then','status','json','format','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','users'];(function(_0x362e1a,_0x6dfa10){var _0x229043=function(_0x399a0d){while(--_0x399a0d){_0x362e1a['push'](_0x362e1a['shift']());}};_0x229043(++_0x6dfa10);}(_0x02f9,0x19a));var _0x902f=function(_0x227427,_0x39a41d){_0x227427=_0x227427-0x0;var _0x2f3aef=_0x02f9[_0x227427];return _0x2f3aef;};'use strict';var crypto=require(_0x902f('0x0'));var util=require(_0x902f('0x1'));var compose=require(_0x902f('0x2'));var db=require(_0x902f('0x3'))['db'];var config=require(_0x902f('0x4'));function getValueFromLicense(_0x6d591,_0x470313){if(_0x6d591&&_0x470313){if(_0x470313[_0x902f('0x5')]&&_0x470313[_0x902f('0x6')]){var _0xf13a55=_0x470313[_0x902f('0x5')];var _0x2a1890=_0x470313[_0x902f('0x6')];var _0x5e2299=_0xf13a55[_0x902f('0x7')]('-')[0x4];var _0x460f2e=_0xf13a55[_0x902f('0x7')]('-')[0x0];var _0x114f24=crypto[_0x902f('0x8')](_0x902f('0x9'),util['format'](_0x902f('0xa'),_0x5e2299,_0xf13a55,_0x460f2e));var _0x3f9ee0=_0x114f24[_0x902f('0xb')](_0x2a1890,_0x902f('0xc'),_0x902f('0xd'));_0x3f9ee0+=_0x114f24[_0x902f('0xe')](_0x902f('0xd'));var _0x4fe7a2=JSON['parse'](_0x3f9ee0);return _0x4fe7a2[_0x902f('0xf')](_0x6d591)?_0x4fe7a2[_0x6d591]:null;}}return null;}function isLimit(_0x8359ac,_0x15ed46,_0x2565fc,_0x12f9db){var _0x4d40a9=_0x15ed46;return compose()['use'](function(_0x4f6efb,_0x425f62,_0x56cc57){return db[_0x902f('0x10')][_0x902f('0x11')]({'where':{'id':0x1},'raw':!![]})[_0x902f('0x12')](function(_0x249860){var _0x271727=getValueFromLicense(_0x8359ac,_0x249860);return _0x271727?_0x271727:_0x4d40a9;})[_0x902f('0x12')](function(_0x1791d4){_0x4d40a9=_0x1791d4;return _0x2565fc['count'](_0x12f9db);})[_0x902f('0x12')](function(_0xa9582f){if(_0xa9582f>=_0x4d40a9){return _0x425f62[_0x902f('0x13')](0x193)[_0x902f('0x14')]({'message':util[_0x902f('0x15')](_0x902f('0x16'),_0x8359ac)});}_0x56cc57();})[_0x902f('0x17')](function(_0xb1554f){_0x56cc57(_0xb1554f);});});}function isUserLimit(){return isLimit(_0x902f('0x18'),0x1,db[_0x902f('0x19')],{'where':{'$or':[{'role':_0x902f('0x1a')},{'role':_0x902f('0x1b')}]}});}exports[_0x902f('0x1c')]=isUserLimit;