Built motion from commit 9e1399f3.|2.5.37
[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 _0x60ae=['admin','user','isUserLimit','crypto','util','composable-middleware','../../mysqldb','../../config/environment','license','data1','split','createDecipher','format','%s:%s:%s','update','base64','utf8','use','findOne','then','count','status','json','Maximum\x20%s\x20limit\x20have\x20been\x20reached','User'];(function(_0x28b10c,_0x350c25){var _0x3b4034=function(_0x55dd84){while(--_0x55dd84){_0x28b10c['push'](_0x28b10c['shift']());}};_0x3b4034(++_0x350c25);}(_0x60ae,0xfd));var _0xe60a=function(_0xe6036b,_0x57ced5){_0xe6036b=_0xe6036b-0x0;var _0x9dd9e=_0x60ae[_0xe6036b];return _0x9dd9e;};'use strict';var crypto=require(_0xe60a('0x0'));var util=require(_0xe60a('0x1'));var compose=require(_0xe60a('0x2'));var db=require(_0xe60a('0x3'))['db'];var config=require(_0xe60a('0x4'));function getValueFromLicense(_0x34471b,_0x27c932){if(_0x34471b&&_0x27c932){if(_0x27c932['data1']&&_0x27c932[_0xe60a('0x5')]){var _0x924611=_0x27c932[_0xe60a('0x6')];var _0x2ef0b4=_0x27c932[_0xe60a('0x5')];var _0x5a6b85=_0x924611[_0xe60a('0x7')]('-')[0x4];var _0x5eddc8=_0x924611['split']('-')[0x0];var _0x1eb2ba=crypto[_0xe60a('0x8')]('aes-256-ctr',util[_0xe60a('0x9')](_0xe60a('0xa'),_0x5a6b85,_0x924611,_0x5eddc8));var _0x4552d5=_0x1eb2ba[_0xe60a('0xb')](_0x2ef0b4,_0xe60a('0xc'),_0xe60a('0xd'));_0x4552d5+=_0x1eb2ba['final'](_0xe60a('0xd'));var _0x5883ff=JSON['parse'](_0x4552d5);return _0x5883ff['hasOwnProperty'](_0x34471b)?_0x5883ff[_0x34471b]:null;}}return null;}function isLimit(_0x2d7d24,_0x4ef2c7,_0x5e40ae,_0x3779b4){var _0x380691=_0x4ef2c7;return compose()[_0xe60a('0xe')](function(_0x272d35,_0x229d7c,_0x264d97){return db['License'][_0xe60a('0xf')]({'where':{'id':0x1},'raw':!![]})[_0xe60a('0x10')](function(_0x9a22f8){var _0x183288=getValueFromLicense(_0x2d7d24,_0x9a22f8);return _0x183288?_0x183288:_0x380691;})[_0xe60a('0x10')](function(_0x590ea8){_0x380691=_0x590ea8;return _0x5e40ae[_0xe60a('0x11')](_0x3779b4);})[_0xe60a('0x10')](function(_0x160065){if(_0x160065>=_0x380691){return _0x229d7c[_0xe60a('0x12')](0x193)[_0xe60a('0x13')]({'message':util[_0xe60a('0x9')](_0xe60a('0x14'),_0x2d7d24)});}_0x264d97();})['catch'](function(_0x43807f){_0x264d97(_0x43807f);});});}function isUserLimit(){return isLimit('users',0x1,db[_0xe60a('0x15')],{'where':{'$or':[{'role':_0xe60a('0x16')},{'role':_0xe60a('0x17')}]}});}exports[_0xe60a('0x18')]=isUserLimit;