Built motion from commit (unavailable).|2.3.0
[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 _0x39b8=['%s:%s:%s','update','base64','utf8','final','parse','hasOwnProperty','use','License','then','count','json','Maximum\x20%s\x20limit\x20have\x20been\x20reached','catch','users','User','admin','user','isUserLimit','util','composable-middleware','../../mysqldb','../../config/environment','data1','license','split','aes-256-ctr','format'];(function(_0x84a85,_0x54e55c){var _0x1c2943=function(_0x99a250){while(--_0x99a250){_0x84a85['push'](_0x84a85['shift']());}};_0x1c2943(++_0x54e55c);}(_0x39b8,0x12b));var _0x839b=function(_0x5b644e,_0x2e5e07){_0x5b644e=_0x5b644e-0x0;var _0x49c6bf=_0x39b8[_0x5b644e];return _0x49c6bf;};'use strict';var crypto=require('crypto');var util=require(_0x839b('0x0'));var compose=require(_0x839b('0x1'));var db=require(_0x839b('0x2'))['db'];var config=require(_0x839b('0x3'));function getValueFromLicense(_0x5ea6a9,_0x136b8b){if(_0x5ea6a9&&_0x136b8b){if(_0x136b8b[_0x839b('0x4')]&&_0x136b8b['license']){var _0x204d12=_0x136b8b['data1'];var _0x3690b9=_0x136b8b[_0x839b('0x5')];var _0x368cdb=_0x204d12[_0x839b('0x6')]('-')[0x4];var _0x2b31f3=_0x204d12['split']('-')[0x0];var _0x54cc15=crypto['createDecipher'](_0x839b('0x7'),util[_0x839b('0x8')](_0x839b('0x9'),_0x368cdb,_0x204d12,_0x2b31f3));var _0x49cc34=_0x54cc15[_0x839b('0xa')](_0x3690b9,_0x839b('0xb'),_0x839b('0xc'));_0x49cc34+=_0x54cc15[_0x839b('0xd')]('utf8');var _0x32fa37=JSON[_0x839b('0xe')](_0x49cc34);return _0x32fa37[_0x839b('0xf')](_0x5ea6a9)?_0x32fa37[_0x5ea6a9]:null;}}return null;}function isLimit(_0x504fb4,_0x5aa044,_0x1609bf,_0x20b62b){var _0x2b9df1=_0x5aa044;return compose()[_0x839b('0x10')](function(_0x4f9638,_0x47c2af,_0x1115f7){return db[_0x839b('0x11')]['findOne']({'where':{'id':0x1},'raw':!![]})[_0x839b('0x12')](function(_0x5132d2){var _0x50ae7b=getValueFromLicense(_0x504fb4,_0x5132d2);return _0x50ae7b?_0x50ae7b:_0x2b9df1;})[_0x839b('0x12')](function(_0x17be5d){_0x2b9df1=_0x17be5d;return _0x1609bf[_0x839b('0x13')](_0x20b62b);})['then'](function(_0x43542e){if(_0x43542e>=_0x2b9df1){return _0x47c2af['status'](0x193)[_0x839b('0x14')]({'message':util[_0x839b('0x8')](_0x839b('0x15'),_0x504fb4)});}_0x1115f7();})[_0x839b('0x16')](function(_0x1acadd){_0x1115f7(_0x1acadd);});});}function isUserLimit(){return isLimit(_0x839b('0x17'),0x1,db[_0x839b('0x18')],{'where':{'$or':[{'role':_0x839b('0x19')},{'role':_0x839b('0x1a')}]}});}exports[_0x839b('0x1b')]=isUserLimit;