Built motion from commit (unavailable).|2.4.20
[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 _0x2481=['User','admin','user','isUserLimit','crypto','util','composable-middleware','../../mysqldb','../../config/environment','license','data1','split','createDecipher','%s:%s:%s','update','base64','utf8','final','use','License','findOne','then','count','status','json','catch','users'];(function(_0x254635,_0x472b4c){var _0x35293c=function(_0x731a6d){while(--_0x731a6d){_0x254635['push'](_0x254635['shift']());}};_0x35293c(++_0x472b4c);}(_0x2481,0x70));var _0x1248=function(_0x3e6b24,_0x2f030c){_0x3e6b24=_0x3e6b24-0x0;var _0xcb806d=_0x2481[_0x3e6b24];return _0xcb806d;};'use strict';var crypto=require(_0x1248('0x0'));var util=require(_0x1248('0x1'));var compose=require(_0x1248('0x2'));var db=require(_0x1248('0x3'))['db'];var config=require(_0x1248('0x4'));function getValueFromLicense(_0x34de2a,_0x40240e){if(_0x34de2a&&_0x40240e){if(_0x40240e['data1']&&_0x40240e[_0x1248('0x5')]){var _0x4660fa=_0x40240e[_0x1248('0x6')];var _0x3da76e=_0x40240e[_0x1248('0x5')];var _0x12fb7d=_0x4660fa[_0x1248('0x7')]('-')[0x4];var _0x54117e=_0x4660fa['split']('-')[0x0];var _0x308c0f=crypto[_0x1248('0x8')]('aes-256-ctr',util['format'](_0x1248('0x9'),_0x12fb7d,_0x4660fa,_0x54117e));var _0x2013cc=_0x308c0f[_0x1248('0xa')](_0x3da76e,_0x1248('0xb'),_0x1248('0xc'));_0x2013cc+=_0x308c0f[_0x1248('0xd')](_0x1248('0xc'));var _0x33fe27=JSON['parse'](_0x2013cc);return _0x33fe27['hasOwnProperty'](_0x34de2a)?_0x33fe27[_0x34de2a]:null;}}return null;}function isLimit(_0x212fc2,_0x38022d,_0xff6e20,_0x499061){var _0x543547=_0x38022d;return compose()[_0x1248('0xe')](function(_0x51a9e6,_0x3188d4,_0x51377f){return db[_0x1248('0xf')][_0x1248('0x10')]({'where':{'id':0x1},'raw':!![]})[_0x1248('0x11')](function(_0x2af34b){var _0x316430=getValueFromLicense(_0x212fc2,_0x2af34b);return _0x316430?_0x316430:_0x543547;})[_0x1248('0x11')](function(_0x4979a4){_0x543547=_0x4979a4;return _0xff6e20[_0x1248('0x12')](_0x499061);})[_0x1248('0x11')](function(_0x42ddd3){if(_0x42ddd3>=_0x543547){return _0x3188d4[_0x1248('0x13')](0x193)[_0x1248('0x14')]({'message':util['format']('Maximum\x20%s\x20limit\x20have\x20been\x20reached',_0x212fc2)});}_0x51377f();})[_0x1248('0x15')](function(_0x13a417){_0x51377f(_0x13a417);});});}function isUserLimit(){return isLimit(_0x1248('0x16'),0x1,db[_0x1248('0x17')],{'where':{'$or':[{'role':_0x1248('0x18')},{'role':_0x1248('0x19')}]}});}exports[_0x1248('0x1a')]=isUserLimit;