Built motion from commit (unavailable).|2.5.26
[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 _0x5f8b=['data1','split','createDecipher','aes-256-ctr','format','%s:%s:%s','update','utf8','final','parse','hasOwnProperty','use','License','then','count','status','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','users','admin','user','isUserLimit','util','composable-middleware','../../mysqldb','license'];(function(_0x37b7b6,_0x165a5c){var _0x10c4c3=function(_0x16d71e){while(--_0x16d71e){_0x37b7b6['push'](_0x37b7b6['shift']());}};_0x10c4c3(++_0x165a5c);}(_0x5f8b,0x100));var _0xb5f8=function(_0x44bcb0,_0x235aa9){_0x44bcb0=_0x44bcb0-0x0;var _0xfaf881=_0x5f8b[_0x44bcb0];return _0xfaf881;};'use strict';var crypto=require('crypto');var util=require(_0xb5f8('0x0'));var compose=require(_0xb5f8('0x1'));var db=require(_0xb5f8('0x2'))['db'];var config=require('../../config/environment');function getValueFromLicense(_0x68e1fc,_0x8f554d){if(_0x68e1fc&&_0x8f554d){if(_0x8f554d['data1']&&_0x8f554d[_0xb5f8('0x3')]){var _0x256294=_0x8f554d[_0xb5f8('0x4')];var _0x3522a1=_0x8f554d[_0xb5f8('0x3')];var _0x1fd96b=_0x256294[_0xb5f8('0x5')]('-')[0x4];var _0x27f3d4=_0x256294[_0xb5f8('0x5')]('-')[0x0];var _0x55dc07=crypto[_0xb5f8('0x6')](_0xb5f8('0x7'),util[_0xb5f8('0x8')](_0xb5f8('0x9'),_0x1fd96b,_0x256294,_0x27f3d4));var _0x4de952=_0x55dc07[_0xb5f8('0xa')](_0x3522a1,'base64',_0xb5f8('0xb'));_0x4de952+=_0x55dc07[_0xb5f8('0xc')](_0xb5f8('0xb'));var _0x4aafca=JSON[_0xb5f8('0xd')](_0x4de952);return _0x4aafca[_0xb5f8('0xe')](_0x68e1fc)?_0x4aafca[_0x68e1fc]:null;}}return null;}function isLimit(_0x56e2aa,_0x19249b,_0x122e1e,_0x1b8a83){var _0x15ad9e=_0x19249b;return compose()[_0xb5f8('0xf')](function(_0xc4a47a,_0x17f204,_0x115e55){return db[_0xb5f8('0x10')]['findOne']({'where':{'id':0x1},'raw':!![]})[_0xb5f8('0x11')](function(_0x5ae301){var _0x40cd5a=getValueFromLicense(_0x56e2aa,_0x5ae301);return _0x40cd5a?_0x40cd5a:_0x15ad9e;})['then'](function(_0x5618fa){_0x15ad9e=_0x5618fa;return _0x122e1e[_0xb5f8('0x12')](_0x1b8a83);})['then'](function(_0x8d1ef6){if(_0x8d1ef6>=_0x15ad9e){return _0x17f204[_0xb5f8('0x13')](0x193)['json']({'message':util[_0xb5f8('0x8')](_0xb5f8('0x14'),_0x56e2aa)});}_0x115e55();})[_0xb5f8('0x15')](function(_0x33fcf8){_0x115e55(_0x33fcf8);});});}function isUserLimit(){return isLimit(_0xb5f8('0x16'),0x1,db['User'],{'where':{'$or':[{'role':_0xb5f8('0x17')},{'role':_0xb5f8('0x18')}]}});}exports[_0xb5f8('0x19')]=isUserLimit;