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 _0x5fc8=['user','isUserLimit','crypto','../../mysqldb','../../config/environment','data1','license','split','createDecipher','aes-256-ctr','format','%s:%s:%s','update','base64','parse','hasOwnProperty','use','License','then','count','status','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','users','User','admin'];(function(_0x485b5d,_0x5692b6){var _0xa90291=function(_0x57ea35){while(--_0x57ea35){_0x485b5d['push'](_0x485b5d['shift']());}};_0xa90291(++_0x5692b6);}(_0x5fc8,0x16e));var _0x85fc=function(_0xe9ff32,_0x29317b){_0xe9ff32=_0xe9ff32-0x0;var _0x533663=_0x5fc8[_0xe9ff32];return _0x533663;};'use strict';var crypto=require(_0x85fc('0x0'));var util=require('util');var compose=require('composable-middleware');var db=require(_0x85fc('0x1'))['db'];var config=require(_0x85fc('0x2'));function getValueFromLicense(_0x39d537,_0x387168){if(_0x39d537&&_0x387168){if(_0x387168[_0x85fc('0x3')]&&_0x387168[_0x85fc('0x4')]){var _0x2a8005=_0x387168[_0x85fc('0x3')];var _0x1d4a38=_0x387168['license'];var _0x4592d3=_0x2a8005[_0x85fc('0x5')]('-')[0x4];var _0x1204c9=_0x2a8005[_0x85fc('0x5')]('-')[0x0];var _0x5a7e68=crypto[_0x85fc('0x6')](_0x85fc('0x7'),util[_0x85fc('0x8')](_0x85fc('0x9'),_0x4592d3,_0x2a8005,_0x1204c9));var _0x324fe8=_0x5a7e68[_0x85fc('0xa')](_0x1d4a38,_0x85fc('0xb'),'utf8');_0x324fe8+=_0x5a7e68['final']('utf8');var _0x27c614=JSON[_0x85fc('0xc')](_0x324fe8);return _0x27c614[_0x85fc('0xd')](_0x39d537)?_0x27c614[_0x39d537]:null;}}return null;}function isLimit(_0x3f6e35,_0x5112ab,_0x1ed96e,_0x312205){var _0x46cf02=_0x5112ab;return compose()[_0x85fc('0xe')](function(_0x16ff87,_0x5c9932,_0x31cbfa){return db[_0x85fc('0xf')]['findOne']({'where':{'id':0x1},'raw':!![]})[_0x85fc('0x10')](function(_0x4ec5bd){var _0x5cddfe=getValueFromLicense(_0x3f6e35,_0x4ec5bd);return _0x5cddfe?_0x5cddfe:_0x46cf02;})[_0x85fc('0x10')](function(_0x322d15){_0x46cf02=_0x322d15;return _0x1ed96e[_0x85fc('0x11')](_0x312205);})[_0x85fc('0x10')](function(_0x183cd6){if(_0x183cd6>=_0x46cf02){return _0x5c9932[_0x85fc('0x12')](0x193)['json']({'message':util[_0x85fc('0x8')](_0x85fc('0x13'),_0x3f6e35)});}_0x31cbfa();})[_0x85fc('0x14')](function(_0x4e1c4a){_0x31cbfa(_0x4e1c4a);});});}function isUserLimit(){return isLimit(_0x85fc('0x15'),0x1,db[_0x85fc('0x16')],{'where':{'$or':[{'role':_0x85fc('0x17')},{'role':_0x85fc('0x18')}]}});}exports[_0x85fc('0x19')]=isUserLimit;