25040f5aad4065e1470470b5eace39b5fbb0eef8
[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 _0xb6a7=['catch','users','User','admin','user','isUserLimit','crypto','util','../../mysqldb','../../config/environment','data1','license','split','createDecipher','%s:%s:%s','base64','utf8','final','parse','hasOwnProperty','use','License','then','count','status','json','format','Maximum\x20%s\x20limit\x20have\x20been\x20reached'];(function(_0x15f3c0,_0x165a64){var _0x1adfe0=function(_0x212cfc){while(--_0x212cfc){_0x15f3c0['push'](_0x15f3c0['shift']());}};_0x1adfe0(++_0x165a64);}(_0xb6a7,0x18e));var _0x7b6a=function(_0x4b4f24,_0x5654a8){_0x4b4f24=_0x4b4f24-0x0;var _0x1c13d4=_0xb6a7[_0x4b4f24];return _0x1c13d4;};'use strict';var crypto=require(_0x7b6a('0x0'));var util=require(_0x7b6a('0x1'));var compose=require('composable-middleware');var db=require(_0x7b6a('0x2'))['db'];var config=require(_0x7b6a('0x3'));function getValueFromLicense(_0x17bdf7,_0x1ed80c){if(_0x17bdf7&&_0x1ed80c){if(_0x1ed80c[_0x7b6a('0x4')]&&_0x1ed80c['license']){var _0x362b88=_0x1ed80c[_0x7b6a('0x4')];var _0x148d5c=_0x1ed80c[_0x7b6a('0x5')];var _0x20ccfa=_0x362b88[_0x7b6a('0x6')]('-')[0x4];var _0x3a087e=_0x362b88[_0x7b6a('0x6')]('-')[0x0];var _0x5649a2=crypto[_0x7b6a('0x7')]('aes-256-ctr',util['format'](_0x7b6a('0x8'),_0x20ccfa,_0x362b88,_0x3a087e));var _0x43ef5c=_0x5649a2['update'](_0x148d5c,_0x7b6a('0x9'),_0x7b6a('0xa'));_0x43ef5c+=_0x5649a2[_0x7b6a('0xb')](_0x7b6a('0xa'));var _0x1cc2fc=JSON[_0x7b6a('0xc')](_0x43ef5c);return _0x1cc2fc[_0x7b6a('0xd')](_0x17bdf7)?_0x1cc2fc[_0x17bdf7]:null;}}return null;}function isLimit(_0x5df7d2,_0x2ce613,_0x431b6b,_0x4b97fb){var _0x5ef4b1=_0x2ce613;return compose()[_0x7b6a('0xe')](function(_0x261bf7,_0x4ec2d1,_0x1dfa3e){return db[_0x7b6a('0xf')]['findOne']({'where':{'id':0x1},'raw':!![]})['then'](function(_0x4fda69){var _0x44026d=getValueFromLicense(_0x5df7d2,_0x4fda69);return _0x44026d?_0x44026d:_0x5ef4b1;})[_0x7b6a('0x10')](function(_0x3952b7){_0x5ef4b1=_0x3952b7;return _0x431b6b[_0x7b6a('0x11')](_0x4b97fb);})[_0x7b6a('0x10')](function(_0x15964e){if(_0x15964e>=_0x5ef4b1){return _0x4ec2d1[_0x7b6a('0x12')](0x193)[_0x7b6a('0x13')]({'message':util[_0x7b6a('0x14')](_0x7b6a('0x15'),_0x5df7d2)});}_0x1dfa3e();})[_0x7b6a('0x16')](function(_0x477841){_0x1dfa3e(_0x477841);});});}function isUserLimit(){return isLimit(_0x7b6a('0x17'),0x1,db[_0x7b6a('0x18')],{'where':{'$or':[{'role':_0x7b6a('0x19')},{'role':_0x7b6a('0x1a')}]}});}exports[_0x7b6a('0x1b')]=isUserLimit;