Built motion from commit e1760111.|2.6.18
[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 _0x1ec2=['json','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','users','User','admin','user','isUserLimit','crypto','util','composable-middleware','../../mysqldb','data1','license','split','createDecipher','aes-256-ctr','format','update','base64','parse','hasOwnProperty','License','findOne','then','count','status'];(function(_0x2147c1,_0x4e6012){var _0x439d69=function(_0x12ef53){while(--_0x12ef53){_0x2147c1['push'](_0x2147c1['shift']());}};_0x439d69(++_0x4e6012);}(_0x1ec2,0x182));var _0x21ec=function(_0x491a7f,_0x28bb80){_0x491a7f=_0x491a7f-0x0;var _0x3d8f44=_0x1ec2[_0x491a7f];return _0x3d8f44;};'use strict';var crypto=require(_0x21ec('0x0'));var util=require(_0x21ec('0x1'));var compose=require(_0x21ec('0x2'));var db=require(_0x21ec('0x3'))['db'];var config=require('../../config/environment');function getValueFromLicense(_0x44164e,_0x159c01){if(_0x44164e&&_0x159c01){if(_0x159c01[_0x21ec('0x4')]&&_0x159c01[_0x21ec('0x5')]){var _0x355a84=_0x159c01[_0x21ec('0x4')];var _0x41d6fc=_0x159c01[_0x21ec('0x5')];var _0x30f710=_0x355a84['split']('-')[0x4];var _0x4b02c2=_0x355a84[_0x21ec('0x6')]('-')[0x0];var _0x1dafa1=crypto[_0x21ec('0x7')](_0x21ec('0x8'),util[_0x21ec('0x9')]('%s:%s:%s',_0x30f710,_0x355a84,_0x4b02c2));var _0x2fcce6=_0x1dafa1[_0x21ec('0xa')](_0x41d6fc,_0x21ec('0xb'),'utf8');_0x2fcce6+=_0x1dafa1['final']('utf8');var _0x1bd353=JSON[_0x21ec('0xc')](_0x2fcce6);return _0x1bd353[_0x21ec('0xd')](_0x44164e)?_0x1bd353[_0x44164e]:null;}}return null;}function isLimit(_0x2fbcad,_0x16d7c5,_0x5b1331,_0xdfeef6){var _0xfa2835=_0x16d7c5;return compose()['use'](function(_0x37c844,_0x412747,_0x1c168e){return db[_0x21ec('0xe')][_0x21ec('0xf')]({'where':{'id':0x1},'raw':!![]})['then'](function(_0xb4391d){var _0xba63ab=getValueFromLicense(_0x2fbcad,_0xb4391d);return _0xba63ab?_0xba63ab:_0xfa2835;})[_0x21ec('0x10')](function(_0x3ce680){_0xfa2835=_0x3ce680;return _0x5b1331[_0x21ec('0x11')](_0xdfeef6);})['then'](function(_0x370f78){if(_0x370f78>=_0xfa2835){return _0x412747[_0x21ec('0x12')](0x193)[_0x21ec('0x13')]({'message':util['format'](_0x21ec('0x14'),_0x2fbcad)});}_0x1c168e();})[_0x21ec('0x15')](function(_0x16e482){_0x1c168e(_0x16e482);});});}function isUserLimit(){return isLimit(_0x21ec('0x16'),0x1,db[_0x21ec('0x17')],{'where':{'$or':[{'role':_0x21ec('0x18')},{'role':_0x21ec('0x19')}]}});}exports[_0x21ec('0x1a')]=isUserLimit;