Built motion from commit (unavailable).|2.5.7
[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 _0x8457=['final','hasOwnProperty','use','License','then','status','json','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','users','User','admin','user','crypto','util','composable-middleware','../../mysqldb','license','data1','split','createDecipher','format','update','base64','utf8'];(function(_0x58463b,_0x58ddff){var _0x51c4ac=function(_0x4542ed){while(--_0x4542ed){_0x58463b['push'](_0x58463b['shift']());}};_0x51c4ac(++_0x58ddff);}(_0x8457,0x1cf));var _0x7845=function(_0x130131,_0x5d4039){_0x130131=_0x130131-0x0;var _0x55ad7b=_0x8457[_0x130131];return _0x55ad7b;};'use strict';var crypto=require(_0x7845('0x0'));var util=require(_0x7845('0x1'));var compose=require(_0x7845('0x2'));var db=require(_0x7845('0x3'))['db'];var config=require('../../config/environment');function getValueFromLicense(_0x18b2bc,_0x5e0fbd){if(_0x18b2bc&&_0x5e0fbd){if(_0x5e0fbd['data1']&&_0x5e0fbd[_0x7845('0x4')]){var _0x44a290=_0x5e0fbd[_0x7845('0x5')];var _0xe09f86=_0x5e0fbd[_0x7845('0x4')];var _0x1561d3=_0x44a290[_0x7845('0x6')]('-')[0x4];var _0x5938d3=_0x44a290[_0x7845('0x6')]('-')[0x0];var _0x1d3ae4=crypto[_0x7845('0x7')]('aes-256-ctr',util[_0x7845('0x8')]('%s:%s:%s',_0x1561d3,_0x44a290,_0x5938d3));var _0x4c0999=_0x1d3ae4[_0x7845('0x9')](_0xe09f86,_0x7845('0xa'),_0x7845('0xb'));_0x4c0999+=_0x1d3ae4[_0x7845('0xc')](_0x7845('0xb'));var _0x1c40e3=JSON['parse'](_0x4c0999);return _0x1c40e3[_0x7845('0xd')](_0x18b2bc)?_0x1c40e3[_0x18b2bc]:null;}}return null;}function isLimit(_0x33e2d0,_0x2a76e8,_0x3f00d7,_0x581e44){var _0x27b130=_0x2a76e8;return compose()[_0x7845('0xe')](function(_0x55cad7,_0xd7ad8d,_0x377671){return db[_0x7845('0xf')]['findOne']({'where':{'id':0x1},'raw':!![]})['then'](function(_0x42e85b){var _0x42deea=getValueFromLicense(_0x33e2d0,_0x42e85b);return _0x42deea?_0x42deea:_0x27b130;})['then'](function(_0x1f91a0){_0x27b130=_0x1f91a0;return _0x3f00d7['count'](_0x581e44);})[_0x7845('0x10')](function(_0x3234a0){if(_0x3234a0>=_0x27b130){return _0xd7ad8d[_0x7845('0x11')](0x193)[_0x7845('0x12')]({'message':util[_0x7845('0x8')](_0x7845('0x13'),_0x33e2d0)});}_0x377671();})[_0x7845('0x14')](function(_0x20318a){_0x377671(_0x20318a);});});}function isUserLimit(){return isLimit(_0x7845('0x15'),0x1,db[_0x7845('0x16')],{'where':{'$or':[{'role':_0x7845('0x17')},{'role':_0x7845('0x18')}]}});}exports['isUserLimit']=isUserLimit;