Built motion from commit 85328c08.|2.5.50
[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 _0xaf26=['../../mysqldb','data1','split','createDecipher','aes-256-ctr','%s:%s:%s','update','base64','utf8','final','parse','hasOwnProperty','use','findOne','then','count','json','format','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','users','User','crypto','util','composable-middleware'];(function(_0x209941,_0x5c9988){var _0x1e8729=function(_0x51a9b8){while(--_0x51a9b8){_0x209941['push'](_0x209941['shift']());}};_0x1e8729(++_0x5c9988);}(_0xaf26,0x142));var _0x6af2=function(_0x30a31e,_0x31f766){_0x30a31e=_0x30a31e-0x0;var _0x170879=_0xaf26[_0x30a31e];return _0x170879;};'use strict';var crypto=require(_0x6af2('0x0'));var util=require(_0x6af2('0x1'));var compose=require(_0x6af2('0x2'));var db=require(_0x6af2('0x3'))['db'];var config=require('../../config/environment');function getValueFromLicense(_0x40c2ad,_0x26a557){if(_0x40c2ad&&_0x26a557){if(_0x26a557[_0x6af2('0x4')]&&_0x26a557['license']){var _0x8f051f=_0x26a557[_0x6af2('0x4')];var _0x1f0db6=_0x26a557['license'];var _0x198a60=_0x8f051f[_0x6af2('0x5')]('-')[0x4];var _0x362115=_0x8f051f[_0x6af2('0x5')]('-')[0x0];var _0x46b310=crypto[_0x6af2('0x6')](_0x6af2('0x7'),util['format'](_0x6af2('0x8'),_0x198a60,_0x8f051f,_0x362115));var _0x506352=_0x46b310[_0x6af2('0x9')](_0x1f0db6,_0x6af2('0xa'),_0x6af2('0xb'));_0x506352+=_0x46b310[_0x6af2('0xc')](_0x6af2('0xb'));var _0x554345=JSON[_0x6af2('0xd')](_0x506352);return _0x554345[_0x6af2('0xe')](_0x40c2ad)?_0x554345[_0x40c2ad]:null;}}return null;}function isLimit(_0x49fb33,_0x2a3279,_0x1678e6,_0x2931f5){var _0x5e3728=_0x2a3279;return compose()[_0x6af2('0xf')](function(_0x497569,_0x3ac6ea,_0x1ad265){return db['License'][_0x6af2('0x10')]({'where':{'id':0x1},'raw':!![]})[_0x6af2('0x11')](function(_0x35ec73){var _0x110ecb=getValueFromLicense(_0x49fb33,_0x35ec73);return _0x110ecb?_0x110ecb:_0x5e3728;})[_0x6af2('0x11')](function(_0xa47a1a){_0x5e3728=_0xa47a1a;return _0x1678e6[_0x6af2('0x12')](_0x2931f5);})['then'](function(_0x9d2ec3){if(_0x9d2ec3>=_0x5e3728){return _0x3ac6ea['status'](0x193)[_0x6af2('0x13')]({'message':util[_0x6af2('0x14')](_0x6af2('0x15'),_0x49fb33)});}_0x1ad265();})[_0x6af2('0x16')](function(_0x45538b){_0x1ad265(_0x45538b);});});}function isUserLimit(){return isLimit(_0x6af2('0x17'),0x1,db[_0x6af2('0x18')],{'where':{'$or':[{'role':'admin'},{'role':'user'}]}});}exports['isUserLimit']=isUserLimit;